From 78dcd8e03f7dcfc8c7cb06d5f824dd6170806e99 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 19 Aug 2007 09:46:15 +0000 Subject: - Patch #155621 by pwolanin: Use API function to delete menu links during rebuild. --- includes/menu.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'includes') 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']); + } } /** -- cgit v1.2.3