mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-17 17:04:08 +00:00
Fixed PermissibleBase->clearPermissions() not unsubscribing from permissions that aren't explicitly assigned
This came to light after observing cfb6856634f91930f6e013e7b98edb638dea15d9 in a fresh light. I noticed that this fix should not have been necessary because clearPermissions() should have dealt with it. Unfortunately, permissions can be set without being set in PermissibleBase->permissions, so this misses things.
This commit is contained in:
parent
bfbc845efa
commit
5863d4c066
@ -166,9 +166,7 @@ class PermissibleBase implements Permissible{
|
|||||||
|
|
||||||
public function clearPermissions(){
|
public function clearPermissions(){
|
||||||
$pluginManager = Server::getInstance()->getPluginManager();
|
$pluginManager = Server::getInstance()->getPluginManager();
|
||||||
foreach(array_keys($this->permissions) as $name){
|
$pluginManager->unsubscribeFromAllPermissions($this->parent ?? $this);
|
||||||
$pluginManager->unsubscribeFromPermission($name, $this->parent ?? $this);
|
|
||||||
}
|
|
||||||
|
|
||||||
$pluginManager->unsubscribeFromDefaultPerms(false, $this->parent ?? $this);
|
$pluginManager->unsubscribeFromDefaultPerms(false, $this->parent ?? $this);
|
||||||
$pluginManager->unsubscribeFromDefaultPerms(true, $this->parent ?? $this);
|
$pluginManager->unsubscribeFromDefaultPerms(true, $this->parent ?? $this);
|
||||||
|
@ -534,6 +534,18 @@ class PluginManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Permissible $permissible
|
||||||
|
*/
|
||||||
|
public function unsubscribeFromAllPermissions(Permissible $permissible) : void{
|
||||||
|
foreach($this->permSubs as $permission => &$subs){
|
||||||
|
unset($subs[spl_object_hash($permissible)]);
|
||||||
|
if(empty($subs)){
|
||||||
|
unset($this->permSubs[$permission]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $permission
|
* @param string $permission
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user