I'm getting the following error after installing the module:

Notice: Trying to get property of non-object in config_perms_menu_alter() (line 109 of /var/www/dev/sites/all/modules/contrib/config_perms/config_perms.module).
Warning: Invalid argument supplied for foreach() in config_perms_menu_alter() (line 109 of /var/www/dev/sites/all/modules/contrib/config_perms/config_perms.module).

I also get this same error any time I clear the cache. Any ideas?

Thanks,
Ben

Comments

jibize’s picture

Hi there,

I'm having the same issue...

askibinski’s picture

sub

jason.fisher’s picture

Same issue in 6.x .. this is blocking Aegir.

Anonymous’s picture

Also having this problem, I did a little debugging. Because I'm not familair with creating patches as recommended I describe the solution in the simple way.

In config_perms/config_perms.module change the function 'function config_perms_perms()' in:

function config_perms_perms($machine_name = NULL, $rebuild = FALSE) {
// Load current perms
// $perms = cache_get('config_perms');

// Rebuild if not there
// if (!$perms || $rebuild) {
$perms = config_perms_cache_rebuild();
// }

return ($machine_name) ? $perms[$machine_name] : $perms;

}

I'm not familair with the function 'cache_get' but I suppose that this function call is the cause of the problem. By unconditionally calling config_perms_cache_rebuild() this problem is circumvented. There must be a better solution but this one works, not unimportant!

richard.wyke’s picture

I think this is because of the way cache_get returns data as an object which config_perms_menu_alter isn't expecting, a fix here to get from the cache properly:

Change:

function config_perms_perms($machine_name = NULL, $rebuild = FALSE) {
  // Load current perms
  $perms = cache_get('config_perms');

  // Rebuild if not there
  if (!$perms || $rebuild) {
    $perms = config_perms_cache_rebuild();
  }

  return ($machine_name) ? $perms[$machine_name] : $perms;
}
function config_perms_perms($machine_name = NULL, $rebuild = NULL) {
  // Load current perms
  $cache_obj = cache_get('config_perms');
  $perms = (is_object($cache_obj) && isset($cache_obj->data)) ? $cache_obj->data : false;

  // Rebuild if not there
  if (!$perms || $rebuild) {
    $perms = config_perms_cache_rebuild();
  }

  return ($machine_name) ? $perms[$machine_name] : $perms;
}
jonhattan’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new618 bytes

Solution in #5 just works.

Attached a patch implementing #5.

3rdLOF’s picture

Last Patch did it.

Many thanks

anniegreens’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new618 bytes

Attached patch re-rolled with correct Drupal standard file permissions (644).

dkingofpa’s picture

Patch in #8 fixed my issue. I wasn't getting the exact same error message, but it was on the same line and this patch worked.

Invalid argument supplied for foreach() config_perms.module:109

jonhattan’s picture

Status: Needs review » Reviewed & tested by the community
Leeteq’s picture

Time to push this one to the -dev branch?

rooby’s picture

Works for me too and the patch looks good. +1 for RTBC

barraponto’s picture

+1 for RTBC. Not working for me on a Panopoly install. Yet works fine on simplytest.me.

barraponto’s picture

drupov’s picture

Patch from #8 works against the latest dev.

druplr’s picture

#8 Fixed the the following error on admin/people with 7.x-2.0+4-dev.
Notice: Trying to get property of non-object in config_perms_permission() (line 55 of .../modules/o_contrib_seven/config_perms/config_perms.module).
+1 for RTBC

tanmayk’s picture

Issue summary: View changes

#8 works against latest dev.
+1 for RTBC

mlncn’s picture

Status: Reviewed & tested by the community » Closed (duplicate)
Related issues: +#2200925: On cache clear: Invalid argument supplied for foreach() - config_perms.module

This is also a duplicate of #2200925: On cache clear: Invalid argument supplied for foreach() - config_perms.module (though i didn't realize until i went to apply it).

Unless i'm missing something?