Warning: Invalid argument supplied for foreach() in menu_unserialize() (line 400 of /var/www/kwpkrakow/includes/menu.inc).
I'm not sure what is the reason of this warning, probably it started to show when I started to use multilingual menu - but I'm not sure about it.
No matter what - here is the solution for this problem:
function menu_unserialize($data, $map) {
if ($data = unserialize($data)) {
+ if ((!is_array($data)) && (!is_object($data))) {
+ return $data;
+ }
foreach ($data as $k => $v) {
if (is_int($v)) {
$data[$k] = isset($map[$v]) ? $map[$v] : '';
Maybe it will be useful for someone.
Comments
Comment #1
johnvThis is a duplicate of #277018: Warning: Invalid argument supplied for foreach() in menu_unserialize() if unserialize returns non-array value
Comment #2
rukayya CreditAttribution: rukayya commentedInvalid argument supplied for foreach() in menu_unserialize() (line 400 of C:\Documents and Settings\rukshaik\Sites\acquia-drupal\includes\menu.inc).
Can anyone tell me what is the cause of this?
Comment #3
aronanda CreditAttribution: aronanda commentedAlso a duplicate of hook_menu path does not working.
I fixed it by including in my hook_menu:
Comment #4
CarlHinton CreditAttribution: CarlHinton as a volunteer and commentedThe serialization warning will disappear if you use
Comment #5
Vali Hutchison CreditAttribution: Vali Hutchison commentedSame applies if you use access arguments to control form access via user permissions - wrap permission(s) in an array:
Comment #6
CProfessionals CreditAttribution: CProfessionals commentedThank you this was exactly my issue. Obscure error. Solution hit the bulls-eye.
Comment #7
ashutosh.mishra CreditAttribution: ashutosh.mishra commentedI have used below mentioned code . its working for me.
function menu_unserialize($data, $map) {
if ($data = unserialize($data)) {
if (is_array($data)) {
foreach ($data as $k => $v) {
if (is_int($v)) {
$data[$k] = isset($map[$v]) ? $map[$v] : '';
}
}