Hello,

I am using Drupal 7.8, and when I am in admin website I got the message

Notice: Undefined index: main-menu in menu_block_view() (line 462 of /modules/menu/menu.module).

I can't remember what I have done the last before it error came up, maybe this issue: 1319484 was a reason for it came up.

Comments

marcingy’s picture

Priority: Critical » Normal
jhammer98’s picture

I just finished installing the latest version of the martplug install profile and received pretty much the same error except I got three of them:

Notice: Undefined index: menu-shop in menu_block_view() (line 462 of /var/www/martplug/modules/menu/menu.module).
Notice: Undefined index: menu-about in menu_block_view() (line 462 of /var/www/martplug/modules/menu/menu.module).
Notice: Undefined index: menu-legal in menu_block_view() (line 462 of /var/www/martplug/modules/menu/menu.module).

Right after the install process completed I went to the home page and was immediately greeted with those messages, I haven't done anything else to 'deflower' the system at this point.

The latest drupal core seemed to install just fine...

jhammer98’s picture

truls1502,

This may or may not be related to your issue but check out issue#1266038 about increasing the timeout parameter in your php.ini file...that took care of my problem:

http://drupal.org/node/1266038#

authentictech’s picture

Similar problem for me after deleting a custom-made menu. There was still a reference to the deleted menu somewhere in Drupal. For me, I had left a menu block inside a panel on a page somewhere.

I don't know if this describes you as your menu is the main menu and you wouldn't have deleted that (would you?) but it could be a conflict with another module.

You could also try flushing all your Drupal caches (menu cache particularly).

trouble.tribbles’s picture

Hey Authentictech,
I'm having the same issue after deleting menu. Any tricks to finding the reference?

geek-merlin’s picture

i also had this ( with another menu name and in current drupal line 469)

source sais: a menu block that does not exist is tried to display.

how to debug this: (!! change "menu_foo" with your offending menu !!)
* in phpmyadmin do a full search on the offending "%menu-foo%"

this gave me the hint that i left an entry in context.module settings!

if this does not help someone, take the bazooka (not tested):
* install devel.module
* before the offending line insert:

if($delta == 'menu_foo') { dsm(debug_backtrace()); }

have fun!

truls1502’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

I am going to close this ticket. Please re-open the ticket if you still have issue.

fergusong’s picture

Okay, I just upgraded to core 7.52 and this issue recurs.
My workaround, is a hack in menu.module.
Which seems to cure it.
I don't think I'll learn the 'right' way to submit
a patch for this bit of code.
If it is useful, please help yourself.
It has been on my 'core hacks' list for
years, but I forget to apply it this time...

around line 480
Cheer, gjf
/**
* Implements hook_block_view().
*/
function menu_block_view($delta = '') {
$menus = menu_get_menus(FALSE);
/* gjf hack adds the empty check */
if (!empty($menus[$delta])) {
$data['subject'] = check_plain($menus[$delta]);
}
// end gjf hack
$data['content'] = menu_tree($delta);
// Add contextual links for this block.
if (!empty($data['content'])) {
$data['content']['#contextual_links']['menu'] = array('admin/structure/menu/manage', array($delta));
}
return $data;
}

Mike Lewis’s picture

Hi,

I just ran into this issue on 7.x-5.2 as well. In my case, I'm trying to load the menu block programmatically for my own purposes. I used devel to print the menu array that it says the index is undefined in, and there's a value in there. I don't know what's going on, but the old "wrap an isset around it" band-aid worked for me.

Here's a patch.

Hope this helps.

sobi3ch’s picture

So I fixed this removing FALSE from menu_get_menus(FALSE) (Exact line in code).

Reading api for menu_get_menus you can find out that

If FALSE return only user-added menus, or if TRUE also include the menus defined by the system.

And I injected programmatically system (menu) block to my global page tempalte and with FALSE parameter this block (main-menu) is not returned. So removing parameter from function in core module it's obvious hack. The easiest solution I see is to create patch for it.

I hope this can help somehow.