Links to <front> and addresses outside of drupal are given a router_path of '' (empty string) in the menu_links table. Each time the menu is rebuilt, _menu_navigation_links_rebuild checks to make sure that all of the links belong to an existing router_path. '' (empty string) is not in this list, so all links to <front> or addresses outside of drupal are removed every time the menu is rebuilt. The removal is done at this line:

db_query('DELETE FROM {menu_links} WHERE router_path NOT IN ('. $placeholders .')', array_keys($menu));

The issue can be fixed by adding '' to the list of valid router_paths, like this:

db_query('DELETE FROM {menu_links} WHERE router_path NOT IN (\'\', '. $placeholders .')', array_keys($menu));

It could also be fixed by checking to make sure router_path is not empty. I'm not sure which way is more consistent with the way things are done in drupal core, I'll leave that up to the reviewer.

The patch for this fix is attached.

CommentFileSizeAuthor
#1 menu_109.patch704 bytesjbratton
menu_108.patch706 bytesjbratton

Comments

jbratton’s picture

StatusFileSize
new704 bytes

Changed to get rid of the ugly escaped quotes. Updated patch is attached.

chx’s picture

Status: Needs review » Postponed (maintainer needs more info)

How did you get empty paths? is hardly a legal path. it should be variable_get('site_frontpage', 'node') . Next up, external links. You can add external links with menu module those get stored in menu_links but what this has to do with the menu_router table? Are you defining external links in hook_menu? If you want such links programmed , use menu_link_save . I am really curious how you ended up with empty menu_router paths.

pwolanin’s picture

Status: Postponed (maintainer needs more info) » Needs work

This looks like a possible fix, but maybe we should use some other path as meaning 'external'? '%' for example? or '-external-'

pwolanin’s picture

Status: Needs work » Closed (duplicate)

will be fixed in this issue: http://drupal.org/node/155621