I have Local Menu installed on a site as well as Drupal Administration Menu, and I've run into an issue where if a page / item does not belong to the menu Primary Links or other specific menu, it can default to belonging to the menu 'admin_menu'. In the case where this happens, there is a conflict and unexpected things happen such as setting the title of the page (and the local menu block) to some cryptic code – very undesirable, and happens unpredictably. My assumption is that you would almost never want this block to show up for an item that's part of the 'admin_menu' menu. I've altered one line of code to cause this module NOT to select that menu ever and set it as the active menu. I'm not sure if this is the best way of making this change, but it's worked so far for me. I just changed the SQL statement on line 74 to 'unselect' admin_menu as an option:

$link	= menu_link_load(db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND hidden <> 1 AND menu_name != 'admin_menu'", $item['href'])));

Comments

pwolanin’s picture

I agree that the sloppy select is the problem, but this module could run into the same problem with book module, or any other module using the menu_links table. The bug is not specific to admin_menu, so the fix should not be either. Note: LINK PATHS ARE NOT UNIQUE.

If you want the link saved by the system module for this path (which should be unique), change the query to specify that:


$link    = menu_link_load(db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND hidden = 0 AND module = 'system'", $item['href'])));

Also note, you probably want hidden = 0, since that column can have values, 1, 0, or -1.

There looks to be one or two other queries that likely need the same change in the module.

sun’s picture

Title: Conflict with Drupal Administration Menu » Link paths are not unique
Priority: Normal » Critical
deshilachado’s picture

Status: Active » Reviewed & tested by the community

This bug makes the simulataneous use of local_menu and admin_menu impossible and it really should be fixed!
As explained in #279767: User counter is output on login page for anonymous users comment #34 and #37 this is a problem of local_menu and should be fixed here.

There are only two database queries in local_menu module, on is in line 74 and the other is in line 85.
Altering line 74 as proposed by pwolanin in comment#1 fixes the problem for me.

deshilachado’s picture

Status: Reviewed & tested by the community » Needs work

Well. altering the line as proposed by pwolanin fixes the problem of the broken user form but it also breaks local_menu.
So, allthough this doesn't solve the problem systematically, I will use a mix of the two proposed lines:

$link    = menu_link_load(db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND hidden = 0 AND menu_name != 'admin_menu'", $item['href'])));
seancorrales’s picture

Tried out the code in #4 and it worked great! Thanks deshilachado!

xurizaemon’s picture

Which modules to whitelist or blacklist is probably dependent on how you're using local_menu. While whitelisting 'system' module worked for pwolanin above, I also needed to whitelist 'menu' module (which may have been the same result that descilachado and scorrales achieved by blacklisting admin_menu).

Another module which is known to have issues playing nicely with admin_menu is menu_breadcrumb (#303247: Menu Breadcrumb setting active menu to undesirable menus).

The patch in this comment by webrascal on the menu breadcrumb issue adds a blacklist (by default: admin_menu, devel) and the ability to exclude other menu-providing modules. This seems flexible and should solve the problem for most people.

Can anyone see a reason that a similar solution wouldn't suit this case?

dave reid’s picture

Version: 6.x-1.5 » 6.x-1.x-dev
Priority: Critical » Normal

Until a better workaround can be found, I committed a fix to ignore the admin_menu and devel menu items.