1
0
Fork 0
mirror of synced 2024-09-29 17:01:37 +13:00

Append type to open bracket to ensure permissions containing a permission type name are not removed

This commit is contained in:
Jake Barnby 2022-08-09 13:23:03 +12:00
parent e2cf49aefd
commit 1ddd34059b

View file

@ -23,7 +23,7 @@ class PermissionsProcessor
if (!\str_starts_with($permission, $type)) {
continue;
}
$permissionsContents = \str_replace([$type, '(', ')', ' '], '', $permission);
$permissionsContents = \str_replace([$type . '(', ')', ' '], '', $permission);
foreach ($subTypes as $subType) {
$permissions[] = $subType . '(' . $permissionsContents . ')';
}
@ -48,6 +48,7 @@ class PermissionsProcessor
return $permissions;
}
foreach (Database::PERMISSIONS as $permission) {
// Default any missing permisions to the current user
if (empty(\preg_grep("#^{$permission}\(.+\)$#", $permissions)) && !empty($userId)) {
$permissions[] = $permission . '(user:' . $userId . ')';
}