The config_perms_perms() function is expected to return an array of the configured permissions, or a specific permission if a machine name has been provided. When the configuration is loaded from the cache, the actual configuration is stored at the data property for the cache object, but the function uses the $perms variable as if it was an array.

This will create problems when the return value of the config_perms_perms() is used as an array in foreach loops, for example. This could be found in config_perms_menu_alter().

The solution to this would be to normalize the $perms variable in order to maintain a consistent data structure within the config_perms_perms() function. The result of this would be that the rest of the code within the module can safely rely on that the structure of the returned variable will always be the same.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

olofbokedal’s picture

mlncn’s picture

Status: Active » Reviewed & tested by the community

This is essentially the same fix as in #2200925: On cache clear: Invalid argument supplied for foreach() - config_perms.module but this one tests for cache existence or rebuild explicitly, and has a better explanatory comment.

Tested and it works, which is also important ;-) Nice work, this issue and patch were also first so marking the other duplicate.

mlncn’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in commit 32f1f27 with credit to olofjohansson.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.