From 26d409c29ca277f7e77b7e89b8afc53112c71f52 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 29 Nov 2020 11:50:20 -0800 Subject: [PATCH] Don't try to flip null values; closes #2753 --- ...03_22_163911_merge_permissions_table_into_subusers.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php index 67461ecc8..f46481b47 100644 --- a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php +++ b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php @@ -83,10 +83,10 @@ class MergePermissionsTableIntoSubusers extends Migration ->map(function ($value) { return self::$permissionsMap[$value] ?? null; })->filter(function ($value) { - return !is_null($value) && $value !== Permission::ACTION_WEBSOCKET_CONNECT; + return ! is_null($value) && $value !== Permission::ACTION_WEBSOCKET_CONNECT; }) // All subusers get this permission, so make sure it gets pushed into the array. - ->merge([ Permission::ACTION_WEBSOCKET_CONNECT ]) + ->merge([Permission::ACTION_WEBSOCKET_CONNECT]) ->unique() ->values() ->toJson(); @@ -103,12 +103,12 @@ class MergePermissionsTableIntoSubusers extends Migration */ public function down() { - $flipped = array_flip(self::$permissionsMap); + $flipped = array_flip(array_filter(self::$permissionsMap)); foreach (DB::select('SELECT id, permissions FROM subusers') as $datum) { $values = []; foreach (json_decode($datum->permissions, true) as $permission) { - if (!empty($v = $flipped[$permission])) { + if (! empty($v = $flipped[$permission])) { $values[] = $datum->id; $values[] = $v; }