mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
PermissionAttachment: better document the apparently nonsensical code responsible for making sure the entire permission system doesn't burn down
This commit is contained in:
parent
ab18332572
commit
ef034f2d68
@ -123,7 +123,16 @@ class PermissionAttachment{
|
|||||||
if($this->permissions[$name] === $value){
|
if($this->permissions[$name] === $value){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unset($this->permissions[$name]); //Fixes children getting overwritten
|
/* Because of the way child permissions are calculated, permissions which were set later in time are
|
||||||
|
* preferred over earlier ones when conflicts in inherited permission values occur.
|
||||||
|
* Here's the kicker: This behaviour depends on PHP's internal array ordering, which maintains insertion
|
||||||
|
* order -- BUT -- assigning to an existing index replaces the old value WITHOUT changing the order.
|
||||||
|
* (what crazy person thought relying on this this was a good idea?!?!?!?!?!)
|
||||||
|
*
|
||||||
|
* This removes the old value so that the new value will be added at the end of the array's internal order
|
||||||
|
* instead of directly taking the place of the older value.
|
||||||
|
*/
|
||||||
|
unset($this->permissions[$name]);
|
||||||
}
|
}
|
||||||
$this->permissions[$name] = $value;
|
$this->permissions[$name] = $value;
|
||||||
$this->permissible->recalculatePermissions();
|
$this->permissible->recalculatePermissions();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user