Warning: Invalid argument supplied for foreach() in zen_preprocess_menu_link() (line 642 of /var/www//sites/all/themes/zen/template.php).
Warning: array_unshift() expects parameter 1 to be array, string given in zen_preprocess_menu_link() (line 651 of /var/www//sites/all/themes/zen/template.php).

I thought it was my module or subtheme, but after disabling both on my site it is still throwing warnings. It appears there is a link somewhere in Zen (or in Drupal core or a contrib module?) that is passing a class to localized options as a string instead of an array.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jedd Casella’s picture

-

JohnAlbin’s picture

$variables['element']['#localized_options']['attributes']['class'] is supposed to be an array, isn't it? That's the way its treated in the menu_block.module. Hmmm…

mermemladeK’s picture

It seems I have similar problem
https://drupal.org/node/2088109

mermemladeK’s picture

I "solved" my PHP errors by downgrading from 7.x-5.4 to 7.x-5.1. Versions 7.x-5.x-dev and 7.x-5.2 did not do the trick for me.
I hope this helps patpluspun and the zen mantainers as well.

blakehall’s picture

I'm not sure if this is the _best_ way to solve the issue, but here's a fix.

We've been seeing this error for quite a while on a multilingual multisite.

Christopher James Francis Rodgers’s picture

I am curious if this is still an issue with Zen 7.x-5.4
since it has been substantially updated
from the train-wreck that 5.3 was... ?

Please respond, so that, if it is not a problem w/ 5.4,
this issue can be closed with the status: "Closed (Won't Fix)"

Thank you for you time, attention, and help.

miogus’s picture

Yes, it is still an issue with Zen 7.x-5.4

The php warning messages are :

Warning: array_unshift() expects parameter 1 to be array, string given in zen_preprocess_menu_link() (line 637 of XXX/sites/all/themes/zen/template.php).

and

Warning: Invalid argument supplied for foreach() in zen_preprocess_menu_link() (line 621 of XXX/sites/all/themes/zen/template.php).

I hope this could help

JohnAlbin’s picture

$variables['element']['#localized_options']['attributes']['class'] is supposed to be an array. Something else in your system is treating it as a string. However, looking at the docs, there's nothing that says it is supposed to be an array.

So I guess, I need to account for strings. *sigh*

chaps2’s picture

I got this after adding a single class to a menu item (classes field of menu item edit form). As a work around I added another dummy class.

  • JohnAlbin committed 0dd1a67 on 7.x-6.x authored by blakehall
    Issue #2058221 by blakehall, JohnAlbin: New version introduces php...

JohnAlbin’s picture

Version: 7.x-5.3 » 7.x-6.x-dev
Status: Active » Fixed

Fixed!

Status: Fixed » Closed (fixed)

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