summaryrefslogtreecommitdiff
path: root/includes/menu.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/menu.inc')
-rw-r--r--includes/menu.inc9
1 files changed, 7 insertions, 2 deletions
diff --git a/includes/menu.inc b/includes/menu.inc
index 105697465..d45054c57 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -1423,8 +1423,13 @@ function _menu_navigation_links_rebuild($menu) {
}
}
$placeholders = implode(', ', array_fill(0, count($menu), "'%s'"));
- // Remove items if their router path does not exist any more.
- db_query('DELETE FROM {menu_links} WHERE router_path NOT IN ('. $placeholders .')', array_keys($menu));
+ // Find any items where their router path does not exist any more.
+ $result = db_query('SELECT mlid FROM {menu_links} WHERE router_path NOT IN ('. $placeholders .') AND external = 0 ORDER BY depth DESC', array_keys($menu));
+ // Remove all such items. Starting from those with the greatest depth will
+ // minimize the amount of re-parenting done by menu_link_delete().
+ while ($item = db_fetch_array($result)) {
+ menu_link_delete($item['mlid']);
+ }
}
/**