Don't try to flip null values; closes #2753
This commit is contained in:
parent
e54612d533
commit
26d409c29c
|
@ -83,10 +83,10 @@ class MergePermissionsTableIntoSubusers extends Migration
|
||||||
->map(function ($value) {
|
->map(function ($value) {
|
||||||
return self::$permissionsMap[$value] ?? null;
|
return self::$permissionsMap[$value] ?? null;
|
||||||
})->filter(function ($value) {
|
})->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.
|
// 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()
|
->unique()
|
||||||
->values()
|
->values()
|
||||||
->toJson();
|
->toJson();
|
||||||
|
@ -103,12 +103,12 @@ class MergePermissionsTableIntoSubusers extends Migration
|
||||||
*/
|
*/
|
||||||
public function down()
|
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) {
|
foreach (DB::select('SELECT id, permissions FROM subusers') as $datum) {
|
||||||
$values = [];
|
$values = [];
|
||||||
foreach (json_decode($datum->permissions, true) as $permission) {
|
foreach (json_decode($datum->permissions, true) as $permission) {
|
||||||
if (!empty($v = $flipped[$permission])) {
|
if (! empty($v = $flipped[$permission])) {
|
||||||
$values[] = $datum->id;
|
$values[] = $datum->id;
|
||||||
$values[] = $v;
|
$values[] = $v;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue