I'm getting repeated logged errors of invalid argument supplied for foreach() for sites/all/modules/jquerymenu/jquerymenu.module on line 207.

Comments

silurius’s picture

Duplicated here under Drupal 6.16 & jquerymenu-6.x-3.0. For reference, here's the relevant line (207):

foreach ($items as $item) {

And the section that it's in:

function recursive_link_creator($items = array(), $trail) {
  $url_array = $trail;
  $i = 0;
  foreach ($items as $item) {
    $classes = array();
    $state = 'closed';
    // If there are submenu items we assign the parent a class.
    if (!empty($item['link']['has_children'])) {
      $nextlevel = '';
      $nextlevel = recursive_link_creator($item['below'],$url_array);
      if (!empty($nextlevel)) {
        $classes[] = 'parent';
      }
    }
Milan0’s picture

Confirmed, error also happening here same versions as described above.

Milan0’s picture

Status: Active » Needs review
StatusFileSize
new24.58 KB
Milan0’s picture

StatusFileSize
new24.58 KB

yuck..windows.
proper filenme now.

not_Dries_Buytaert’s picture

Title: invalid argument supplied for foreach() » Log entry PHP error 'Invalid argument supplied for foreach() in .../sites/all/modules/jquerymenu/jquerymenu.module on line 207.'
Status: Needs review » Reviewed & tested by the community

Since applying the patch and manually running '/admin/reports/status/run-cron', the log entries do not appear anymore. I am unsure which use cases (requiring this module) triggered the error. Nevertheless, I consider I successfully reviewed and tested this patch, which changes the code after line 204 in '.../sites/all/modules/jquerymenu/jquerymenu.module'
from:

function recursive_link_creator($items = array(), $trail) {
  $url_array = $trail;
  $i = 0;
  foreach ($items as $item) {
<...>
  }
    return $output;
}

to:

function recursive_link_creator($items = array(), $trail) {
  $url_array = $trail;
  $i = 0;
 if(!empty($items)){
  foreach ($items as $item) {
<...>
   }
  }
    return $output;
}

Please, could someone include this change into the next release?

PixelClever’s picture

Ok the code here has been changed and committed to HEAD. I want to wait a little bit to see if there are any other things that need work before making a new release.

not_Dries_Buytaert’s picture

A pity that this patch just missed the release d.d. 2010-May-05 (http://drupal.org/node/790206). I also applied and successfully tested the change in that release.

PixelClever’s picture

Status: Reviewed & tested by the community » Fixed
not_Dries_Buytaert’s picture

Version: 6.x-3.0 » 6.x-3.2
Status: Fixed » Closed (fixed)

Just noticed that this issue was solved thanks to this release: jquerymenu 6.x-3.3 (http://drupal.org/node/799538). :-)