From b22973f3ab2f4c767b19b7f91c2cb617bec6b8d0 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 20776df1..03a79d30 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();