Repository navigation
[zend-acl] fix rule removal for numeric ids and for all resources - #238
Open
falkenhawk wants to merge 2 commits into
Open
falkenhawk wants to merge 2 commits into
falkenhawk wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removing roles, resources or rules from
Zend_Aclcan leave rules behind.1) Removed roles and resources with numeric ids keep their rules
php stores array keys like
'5'as integers.removeRole()andremove()look for the rules of the removed role or resource with===, comparing the string id'5'with the integer key5.That never matches, so the rules stay, and a role or resource added later with the same id gets them back:
The same happens with
remove('123')followed byaddResource('123').Both ids are now compared as strings.
2)
removeAllow(null, null)leaves deny rules behindremoveAllow(null, null)should remove the allow rules of all roles on all resources.Instead, it turns the rule for all roles on each single resource into a deny rule:
Only the rule for all roles on all resources - the default rule - should be reset to deny. Every other rule should simply be removed.
The code for a
nullresource list was added for ZF-10649 and checks only the role (zendframework/zf1).It also creates empty rule entries for every resource, which then raise
Undefined array key "allPrivileges"warnings on php 8.removeDeny(null, null)has the same problem.That code now works like the code for a given list of resources right above it: it creates no rule entries, and it resets to deny only when both role and resource are
null.laminas-permissions-acl does the same.
Backwards compatibility
Only the wrong results shown above change.
Ported from a private repository, based on work by @marcing.
removeRole()is fixed in addition.