diff --git a/core/includes/menu.inc b/core/includes/menu.inc index b82a999..1e0e919 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -2464,7 +2464,7 @@ function menu_router_rebuild() { try { list($menu) = menu_router_build(TRUE); - menu_links_rebuild_defaults(); + menu_link_rebuild_defaults(); // Clear the menu, page and block caches. menu_cache_clear_all(); _menu_clear_page_cache(); @@ -2669,8 +2669,8 @@ function menu_link_rebuild_defaults() { } else { if (empty($link['route_name']) && empty($link['link_path'])) { - $link['route_name'] = ''; - $link['link_title'] = 'THIS IS A BUG'; + watchdog('error', 'Menu_link %machine_name does neither provide a route_name nor a lin_path, so it got skipped.'); + continue; } $menu_link = $menu_link_storage->createFromDefaultLink($link); } @@ -2703,13 +2703,18 @@ function menu_link_rebuild_defaults() { } // Find any item whose router path does not exist any more. - $query = \Drupal::entityQuery('menu_link') - ->condition('machine_name', array_keys($all_links), 'NOT IN') - ->condition('external', 0) - ->condition('updated', 0) - ->condition('customized', 0) - ->sort('depth', 'DESC'); - $result = $query->execute(); + if ($all_links) { + $query = \Drupal::entityQuery('menu_link') + ->condition('machine_name', array_keys($all_links), 'NOT IN') + ->condition('external', 0) + ->condition('updated', 0) + ->condition('customized', 0) + ->sort('depth', 'DESC'); + $result = $query->execute(); + } + else { + $result = array(); + } // Remove all such items. Starting from those with the greatest depth will // minimize the amount of re-parenting done by the menu link controller. diff --git a/core/modules/menu/menu.install b/core/modules/menu/menu.install index cd02367..3415cdc 100644 --- a/core/modules/menu/menu.install +++ b/core/modules/menu/menu.install @@ -14,7 +14,7 @@ function menu_install() { // Add a link for each custom menu. \Drupal::service('router.builder')->rebuild(); menu_router_rebuild(); - menu_links_rebuild_defaults(); + menu_link_rebuild_defaults(); $system_link = entity_load_multiple_by_properties('menu_link', array('link_path' => 'admin/structure/menu', 'module' => 'system')); $system_link = reset($system_link);