diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-12-06 21:35:14 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-12-06 21:35:14 +0000 |
commit | cd8afc2be1dc62bcad0d691f132aaf37a863237e (patch) | |
tree | e1144362accbd77da064b2f16e2a53fb30eced6c | |
parent | ccf72e94176942e3033b11335957d66f4f9457e1 (diff) | |
download | brdo-cd8afc2be1dc62bcad0d691f132aaf37a863237e.tar.gz brdo-cd8afc2be1dc62bcad0d691f132aaf37a863237e.tar.bz2 |
#196043 by chx: menu items saved in the update but broken on the new system (due to coming from disabled or old modules) were not possible to delete
-rw-r--r-- | includes/menu.inc | 14 | ||||
-rw-r--r-- | modules/menu/menu.admin.inc | 7 | ||||
-rw-r--r-- | modules/system/system.install | 5 |
3 files changed, 12 insertions, 14 deletions
diff --git a/includes/menu.inc b/includes/menu.inc index 0b59c9362..d89629622 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -1598,11 +1598,13 @@ function _menu_navigation_links_rebuild($menu) { } } } - $result = db_query("SELECT ml.link_path, ml.mlid, ml.router_path FROM {menu_links} ml WHERE ml.updated = 1"); + $result = db_query("SELECT ml.link_path, ml.mlid, ml.router_path, ml.updated FROM {menu_links} ml WHERE ml.updated = 1"); while ($item = db_fetch_array($result)) { $router_path = _menu_find_router_path($menu, $item['link_path']); - if (!empty($router_path) && $router_path != $item['router_path']) { - db_query("UPDATE {menu_links} SET router_path = '%s' WHERE mlid = %d", $router_path, $item['mlid']); + if (!empty($router_path) && ($router_path != $item['router_path'] || $item['updated'])) { + // If the router path and the link path matches, it's surely a working + // item, so we clear the updated flag. + db_query("UPDATE {menu_links} SET router_path = '%s', updated = %d WHERE mlid = %d", $router_path, $router_path != $item['link_path'], $item['mlid']); } } } @@ -1631,9 +1633,9 @@ function menu_link_delete($mlid, $path = NULL) { * Helper function for menu_link_delete; deletes a single menu link. */ function _menu_delete_item($item) { - // System-created items are never deleted. - if ($item && ($item['module'] != 'system')) { - + // System-created items are never deleted. Updated items are an exception, + // as they can be broken. + if ($item && ($item['module'] != 'system' || $item['updated'])) { // Children get re-attached to the item's parent. if ($item['has_children']) { $result = db_query("SELECT mlid FROM {menu_links} WHERE plid = %d", $item['mlid']); diff --git a/modules/menu/menu.admin.inc b/modules/menu/menu.admin.inc index 91ecd3050..53972544d 100644 --- a/modules/menu/menu.admin.inc +++ b/modules/menu/menu.admin.inc @@ -95,7 +95,7 @@ function _menu_overview_tree_form($tree) { $operations = array(); $operations['edit'] = l(t('edit'), 'admin/build/menu/item/'. $item['mlid'] .'/edit'); // Only items created by the menu module can be deleted. - if ($item['module'] == 'menu') { + if ($item['module'] == 'menu' || $item['updated'] == 1) { $operations['delete'] = l(t('delete'), 'admin/build/menu/item/'. $item['mlid'] .'/delete'); } // Set the reset column. @@ -534,8 +534,9 @@ function menu_edit_menu_submit($form, &$form_state) { * Menu callback; Check access and present a confirm form for deleting a menu link. */ function menu_item_delete_page($item) { - // Links defined via hook_menu may not be deleted. - if ($item['module'] == 'system') { + // Links defined via hook_menu may not be deleted. Updated items are an + // exception, as they can be broken. + if ($item['module'] == 'system' && !$item['updated']) { drupal_access_denied(); return; } diff --git a/modules/system/system.install b/modules/system/system.install index 810d1a005..682f76a36 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -2327,11 +2327,6 @@ function system_update_6021() { } if ($_SESSION['system_update_6021'] >= $_SESSION['system_update_6021_max']) { - $result = db_query('SELECT * FROM {menu_links} WHERE updated = 1 AND has_children = 0 AND customized = 0 ORDER BY depth DESC'); - // Remove all items that are not customized. - while ($item = db_fetch_array($result)) { - _menu_delete_item($item, TRUE); - } if (!empty($_SESSION['menu_bogus_menus'])) { // Remove entries in bogus menus. This is secure because we deleted // every non-alpanumeric character from the menu name. |