Browse Source

Zend_Acl throws one notice less, and includes the appropriate files. #ZF-8039 & #ZF-8077

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18559 44c647ce-9c0f-0410-b52a-842ac1e357ba
freak 16 years ago
parent
commit
9b317a455b
2 changed files with 32 additions and 2 deletions
  1. 18 2
      library/Zend/Acl.php
  2. 14 0
      tests/Zend/Acl/AclTest.php

+ 18 - 2
library/Zend/Acl.php

@@ -39,6 +39,18 @@ require_once 'Zend/Acl/Assert/Interface.php';
 
 
 /**
+ * @see Zend_Acl_Role
+ */
+require_once 'Zend/Acl/Role.php';
+
+
+/**
+ * @see Zend_Acl_Resource
+ */
+require_once 'Zend/Acl/Resource.php';
+
+
+/**
  * @category   Zend
  * @package    Zend_Acl
  * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
@@ -679,13 +691,17 @@ class Zend_Acl
                                 }
                                 continue;
                             }
-                            if ($type === $rules['allPrivileges']['type']) {
+
+                            if (isset($rules['allPrivileges']['type']) &&
+                                $type === $rules['allPrivileges']['type'])
+                            {
                                 unset($rules['allPrivileges']);
                             }
                         } else {
                             foreach ($privileges as $privilege) {
                                 if (isset($rules['byPrivilegeId'][$privilege]) &&
-                                    $type === $rules['byPrivilegeId'][$privilege]['type']) {
+                                    $type === $rules['byPrivilegeId'][$privilege]['type'])
+                                {
                                     unset($rules['byPrivilegeId'][$privilege]);
                                 }
                             }

+ 14 - 0
tests/Zend/Acl/AclTest.php

@@ -1233,4 +1233,18 @@ class Zend_Acl_AclTest extends PHPUnit_Framework_TestCase
         // Check after fix
         $this->assertFalse($acl->hasRole('test0'));
     }
+    
+    /**
+     * @group ZF-8039
+     * 
+     * Meant to test for the (in)existance of this notice:
+     * "Notice: Undefined index: allPrivileges in lib/Zend/Acl.php on line 682"
+     */
+    public function testMethodRemoveAllowDoesNotThrowNotice() {
+        $acl = new Zend_Acl();
+        $acl->addRole('admin');
+        $acl->addResource('blog');
+        $acl->allow('admin', 'blog', 'read');
+        $acl->removeAllow(array('admin'), array('blog'), null);
+    }
 }