Commit cd8afc2b authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#196043 by chx: menu items saved in the update but broken on the new system...

#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
parent ccf72e94
......@@ -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']);
......
......@@ -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;
}
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment