From 5dcfe80fe479d14d3f6e88d8645d32f7046d92fd Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Mon, 28 Mar 2022 09:11:21 +1300 Subject: [PATCH] BUG: Legacy permissions migration fix. --- src/Model/Locale.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Model/Locale.php b/src/Model/Locale.php index d2510330..40b0eff3 100644 --- a/src/Model/Locale.php +++ b/src/Model/Locale.php @@ -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();