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.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | menu_109.patch | 704 bytes | jbratton |
| menu_108.patch | 706 bytes | jbratton |
Comments
Comment #1
jbratton commentedChanged to get rid of the ugly escaped quotes. Updated patch is attached.
Comment #2
chx commentedHow 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.
Comment #3
pwolanin commentedThis looks like a possible fix, but maybe we should use some other path as meaning 'external'? '%' for example? or '-external-'
Comment #4
pwolanin commentedwill be fixed in this issue: http://drupal.org/node/155621