From 807474b3fbe8a10f527598110376e88c87fbfb9c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 2 Dec 2020 15:56:54 +0000 Subject: [PATCH] PermissibleBase: do not assign any permissions by default there is no longer such a thing as a permission granted to 'everyone', since we're no longer limited to true/false/op/notop, and regular players are now assigned the pocketmine.group.user permission. It's possible we might want to add more restricted groups than 'user' in the future, in which case it would be behaviour-BC-breaking to change the default assigned permissions when creating a new PermissibleBase. Therefore, it's better to not assign any permissions at all and let the caller decide. In addition, this solves the problem of implied permission subscriptions and leak on PermissibleBase construction - if base permissions are provided, it should be expected that the permissible will subscribe to those permissions. --- src/permission/PermissibleBase.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/permission/PermissibleBase.php b/src/permission/PermissibleBase.php index 041057e8a5..3cff6afc18 100644 --- a/src/permission/PermissibleBase.php +++ b/src/permission/PermissibleBase.php @@ -35,9 +35,7 @@ class PermissibleBase implements Permissible{ * @var bool[] * @phpstan-var array */ - private $rootPermissions = [ - DefaultPermissions::ROOT_USER => true - ]; + private $rootPermissions; /** @var PermissionAttachment[] */ private $attachments = []; @@ -60,9 +58,7 @@ class PermissibleBase implements Permissible{ //TODO: we can't setBasePermission here directly due to bad architecture that causes recalculatePermissions to explode //so, this hack has to be done here to prevent permission recalculations until it's fixed... - foreach($basePermissions as $permission => $isGranted){ - $this->rootPermissions[$permission] = $isGranted; - } + $this->rootPermissions = $basePermissions; //TODO: permissions need to be recalculated here, or inherited permissions won't work }