Drupal Warning: Invalid argument supplied for foreach() in admin_menu_merge_tree() (line 210... Fixed
This problem has existed in Drupal 7 with Admininistration Menu for many months. I finally dug into the PHP error and figured it out.
Every time cron would run as mentioned in #8 I would get the following error in Drupal:
Warning: Invalid argument supplied for foreach() in admin_menu_merge_tree() (line 210...
As a work around I went to admin/config/development/logging and turned off all warnings and errors, but it was still filling up my logs. So I researched this php error and found a fix. I edited the file admin_menu.inc and changed from this:
foreach ($load_functions as $index => $function) {
if ($function) {
if (is_array($function)) {
list($function,) = each($function);
}
// Add the loader function name minus "_load".
$placeholder = '%' . substr($function, 0, -5);
$path_args[$index] = $placeholder;
}
}
to this
if(is_array($load_functions)){
foreach ($load_functions as $index => $function) {
if ($function) {
if (is_array($function)) {
list($function,) = each($function);
}
// Add the loader function name minus "_load".
$placeholder = '%' . substr($function, 0, -5);
$path_args[$index] = $placeholder;
}
}
}
The extra check makes sure there is an array before doing the foreach() call.
It works great now. If I knew how to turn this into a patch I would, if someone else does it would be great!