I have this message displayed on the front page. I couldn't find any other reference to a such message in the existing issues.
Any help ?
Here is the full message I've got:
Warning : Invalid argument supplied for foreach() in context_reaction_menu->menu_set_active() (line 96 in /home/xxx/public_html/sites/all/modules/context/plugins/context_reaction_menu.inc).

Comments

tekante’s picture

This is likely due to having a non array for $vars['main_menu'] or $vars['secondary_array'] in hook_preprocess_page. Do you have any code in your site which may lead to this condition?

Gyver06’s picture

Thanks for your answer, but how can I know if there is any code corresponding to one of the two conditions you mentioned ?

tekante’s picture

Looking through other hook_preprocess_page functions may help. As a first step you may want to use the debug function or drupal_set_message to print the value of $vars['main_menu'] and $vars['secondary_array'] to see if that gives you some hints on what may have set the value it contains gives you hints about what modules may be adjusting that value.

Gyver06’s picture

Thank you for your appreciated help.
I have managed and removed finally Context for now. I will need it at a later time.
Hope someone else will face the same issue and resolve it.

Regards

tekante’s picture

Status: Active » Closed (cannot reproduce)

Closing as reporter is unable to provide additional information at this time

lufecir’s picture

I have been able to reproduce this problem. It seems to be coming from the i18n_menu module. As soon as I enable that module, this error occurs.

My versions:
Drupal core 7.18
==========
name = Menu translation
moduleName = i18n_menu
version = "7.x-1.7"
core = "7.x"
project = "i18n"
datestamp = "1341236501"

alpersari’s picture

This error occurred after updating the site to 7.18.

tekante’s picture

Status: Closed (cannot reproduce) » Needs review
StatusFileSize
new564 bytes

I am still unable to replicate the error but can you try the attached patch to see if it resolves it for you.

andrés chandía’s picture

I've got the same problem when updating to i18n-7.x-1.8 (and variable-7.x-2.2)
I've tried with your patch but no success!

andrés chandía’s picture

I have downgraded to i18n 7.x-1.7 and the problem went away

jose reyero’s picture

I think i18n and context modules clash on so many places we should just document the incompatibilities. They just happen to use the same hooks to alter stuff provided by other modules...

Anyway, if anyone wants to keep working on a patch, this is what changed in i18n 7.x-1.8 about menus, if it's any use: #1693074: Change menu translation approach (i18n_menu_translated_menu_link_alter() skips item subtree processing)

knalstaaf’s picture

I have downgraded to i18n 7.x-1.7 and the problem went away

For some reason the issue was solved by upgrading to i18n 7.x-1.8. So the combination Context 7.x-3.0-beta6 and i18n 7.x-1.8 works for me.

bonchak’s picture

I have the same problem:

Notice: Undefined index: main_menu in context_reaction_menu->execute() (line 62 of /home/...../public_html/dr/sites/all/modules/context/plugins/context_reaction_menu.inc).
Notice: Undefined index: secondary_menu in context_reaction_menu->execute() (line 63 of /home/...../public_html/dr/sites/all/modules/context/plugins/context_reaction_menu.inc).

When I downgrade i18n to 7.x-1.7 the problem disappears but due to some other reasons ( string translation of filed group titles ) I am forced to use the latest version of i18n. I've noticed that when I have this error context does not work. Any suggestions?

tekante’s picture

bonchak - does the patch in #8 resolve the issue for you in terms of the error message? Also, if some other module is modifying the expected structure of the links from menu_navigation_links or i18n_menu_navigation_links such that they no longer return an array then the menu reaction won't function correctly.

bonchak’s picture

@tekante: the patch in #8 did not resolve my issue. I am usin i18n and i am supposed to use the updated version. If i use i18n 7.x-1.7 than the problem disappears. However I have to translate fieldgroup titles which requires an updated version of i18n. I've disabled context module for now, and will look for a solution via using rules.

edwtorba’s picture

Issue summary: View changes
Issue tags: +Undefined index main_menu, +context_reaction_menu error
StatusFileSize
new563 bytes

The problem is in the context module, as this module is making a call to the function i18n_menu_preprocess_page. This function ceased to exist since 7.x-1.7 version of the i18n module, so that was added a condition that validates the existence of such a function and providing compatibility with earlier and later versions of the i18n module.

quiron’s picture

Hi folks

I'm having a error marked as duplicated of this one: https://www.drupal.org/node/1918038 I have the following notice:

Notice: Undefined index: main_menu a context_reaction_menu->execute() (línia 62 de /XXX/context/plugins/context_reaction_menu.inc).
Notice: Undefined index: secondary_menu a context_reaction_menu->execute() (línia 63 de /XXX/context/plugins/context_reaction_menu.inc).

this lines have the follow code:

    $vars['main_menu'] = $this->menu_set_active($vars['main_menu']);                                                                                                                                                                                                                                                           
    $vars['secondary_menu'] = $this->menu_set_active($vars['secondary_menu']);

could be a solution wrapp each one with a if (!empty($vars['main/secondary_menu'])) ???

the versions of my source are:
core 7.31
Internationalization 7.x-1.11
Context 7.x-3.2

thank for your support!

andrés chandía’s picture

Status: Needs review » Closed (outdated)