This is probably a bug in views, but nevertheless a check should be in the function.

While using views I created a view with arguments and got the error below on all of the view's pages:

# warning: Invalid argument supplied for foreach() in [blahblah]/includes/menu.inc on line 376.

So I went in there and fixed it. I added:

if (is_array($load_functions)) { // line #376

And the closing bracket on line #420.

This is minor but it's good practice to check that the loop variable is an actual array...

Comments

dpearcefl’s picture

Status: Active » Postponed (maintainer needs more info)

Is this issue fixed in the latest D6? is there any interest in pursuing this issue?

dpearcefl’s picture

Status: Postponed (maintainer needs more info) » Active
johnv’s picture

Title: Minor check in _menu_load_objects » warning: Invalid argument supplied for foreach() in .../includes/menu.inc in _menu_load_objects()
Status: Active » Closed (fixed)

Closing, as there is no response.
In D7.22, this has been corrected. This is the code:

function _menu_load_objects(&$item, &$map) {
  if ($load_functions = $item['load_functions']) {
    // If someone calls this function twice, then unserialize will fail.
    if (!is_array($load_functions)) {
      $load_functions = unserialize($load_functions);
    }