Skip to content
Browse files

[#4226] Fix null resource/privilege assignment

- Prepend `null` to the list of resources when `null` is passed as the
  resource to `allow()`/`deny()`, ensuring that `allPrivileges` gets
  updated correctly.
  • Loading branch information...
1 parent 8c61669 commit 4f4d60ebe730cc5cfd2ffa5018e5c1c4b048fdbc @weierophinney committed Apr 15, 2013
Showing with 7 additions and 0 deletions.
  1. +4 −0 library/Zend/Permissions/Acl/Acl.php
  2. +3 −0 tests/ZendTest/Permissions/Acl/AclTest.php
View
4 library/Zend/Permissions/Acl/Acl.php
@@ -556,6 +556,10 @@ public function setRule($operation, $type, $roles = null, $resources = null,
if (!is_array($resources)) {
if (null === $resources && count($this->resources) > 0) {
$resources = array_keys($this->resources);
+ // Passing a null resource; make sure "global" permission is also set!
+ if (!in_array(null, $resources)) {
+ array_unshift($resources, null);
+ }
} else {
$resources = array($resources);
}
View
3 tests/ZendTest/Permissions/Acl/AclTest.php
@@ -1373,6 +1373,9 @@ public function testSetRuleWorksWithResourceInterface()
$this->_acl->setRule(Acl\Acl::OP_ADD, Acl\Acl::TYPE_ALLOW, $roleGuest, $resourceFoo);
}
+ /**
+ * @group 4226
+ */
public function testAllowNullPermissionAfterResourcesExistShouldAllowAllPermissionsForRole()
{
$this->_acl->addRole('admin');

0 comments on commit 4f4d60e

Please sign in to comment.
Something went wrong with that request. Please try again.