The error is in Zend_Acl::removeRole (on line 201 in Zend Framework 1.8.4).
If we have a resource that only has privileges for all users, then the $visitor array looks like:
I.e. there is no byRoleId key in the $visitor array and so the foreach generates the Undefined Index warning.
Note that removeRole() loops through rules for every resource looking for privileges granted to the role being removed. This means that if there is a Resource that only has privileges for all users, the error occurs regardless of which role is being removed.
This error can be fixed by checking for the byRoleId array key before looping through the roles. I.e. instead of:
foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $visitor) {
foreach ($visitor['byRoleId'] as $roleIdCurrent => $rules) {
if ($roleId === $roleIdCurrent) {
unset($this->_rules['byResourceId'][$resourceIdCurrent]['byRoleId'][$roleIdCurrent]);
}
}
}
we have
foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $visitor) {
if (array_key_exists('byRoleId', $visitor)) {
foreach ($visitor['byRoleId'] as $roleIdCurrent => $rules) {
if ($roleId === $roleIdCurrent) {
unset($this->_rules['byResourceId'][$resourceIdCurrent]['byRoleId'][$roleIdCurrent]);
}
}
}
}
The error is in Zend_Acl::removeRole (on line 201 in Zend Framework 1.8.4).
If we have a resource that only has privileges for all users, then the $visitor array looks like:
I.e. there is no byRoleId key in the $visitor array and so the foreach generates the Undefined Index warning.
Note that removeRole() loops through rules for every resource looking for privileges granted to the role being removed. This means that if there is a Resource that only has privileges for all users, the error occurs regardless of which role is being removed.
This error can be fixed by checking for the byRoleId array key before looping through the roles. I.e. instead of:
we have