diff -u b/core/includes/common.inc b/core/includes/common.inc --- b/core/includes/common.inc +++ b/core/includes/common.inc @@ -6833,7 +6833,6 @@ // Rebuild the menu router based on all rebuilt data. // Important: This rebuild must happen last, so the menu router is guaranteed // to be based on up to date information. - drupal_container()->get('router.builder')->rebuild(); menu_router_rebuild(); // Re-initialize the maintenance theme, if the current request attempted to only in patch2: unchanged: --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -2656,21 +2656,31 @@ function menu_router_rebuild() { return FALSE; } - $transaction = db_transaction(); - - try { - list($menu, $masks) = menu_router_build(); - _menu_router_save($menu, $masks); - _menu_navigation_links_rebuild($menu); - // Clear the menu, page and block caches. - menu_cache_clear_all(); - _menu_clear_page_cache(); - // Indicate that the menu has been successfully rebuilt. - state()->delete('menu_rebuild_needed'); + // @todo Drupal is transitioning from the old menu router to a new router. + // During this transition, have menu_router_rebuild() also rebuild the new + // router. If the new router service isn't available (e.g., during + // update.php until that script transitions to DrupalKernel), delay the + // rebuild until it is. + if (drupal_container()->has('router.builder')) { + $transaction = db_transaction(); + try { + list($menu, $masks) = menu_router_build(); + _menu_router_save($menu, $masks); + _menu_navigation_links_rebuild($menu); + drupal_container()->get('router.builder')->rebuild(); + // Clear the menu, page and block caches. + menu_cache_clear_all(); + _menu_clear_page_cache(); + // Indicate that the menu has been successfully rebuilt. + state()->delete('menu_rebuild_needed'); + } + catch (Exception $e) { + $transaction->rollback(); + watchdog_exception('menu', $e); + } } - catch (Exception $e) { - $transaction->rollback(); - watchdog_exception('menu', $e); + else { + state()->set('menu_rebuild_needed', TRUE); } lock()->release(__FUNCTION__);