Skip to content

Commit

Permalink
Merge pull request #760 from tractorcow-farm/bugfix/legacy-permissions
Browse files Browse the repository at this point in the history
BUG: Legacy permissions migration fix.
  • Loading branch information
tractorcow authored Mar 27, 2022
2 parents f630298 + 5dcfe80 commit 4ba59a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Model/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,18 @@ public function populateDefaults()
*/
protected static $locales_by_title;

public function requireDefaultRecords()
public function requireDefaultRecords(): void
{
parent::requireDefaultRecords();

// Migrate legacy permission codes to new codes
$permissions = Permission::get()->filter('Code:StartsWith', 'CMS_ACCESS_Fluent_');
$count = $permissions->count();

if ($count) {
DB::alteration_message("Migrating ${$count} old fluent permissions", 'changed');
DB::alteration_message(sprintf('Migrating %d old fluent permissions', $count), 'changed');
}

foreach ($permissions as $permission) {
$permission->Code = str_replace('CMS_ACCESS_Fluent_', 'Fluent_', $permission->Code);
$permission->write();
Expand Down

0 comments on commit 4ba59a5

Please sign in to comment.