diff --git a/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php index de44113..a996054 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php @@ -59,27 +59,7 @@ public function onRouterRebuild(Event $event) { * Perform menu-specific rebuilding. */ protected function menuLinksRebuild() { - if ($this->lock->acquire(__FUNCTION__)) { - $transaction = db_transaction(); - try { - // Ensure the menu links are up to date. - $this->menuLinkManager->rebuild(); - // Ignore any database replicas temporarily. - db_ignore_replica(); - } - catch (\Exception $e) { - $transaction->rollback(); - watchdog_exception('menu', $e); - } - - $this->lock->release(__FUNCTION__); - } - else { - // Wait for another request that is already doing this work. - // We choose to block here since otherwise the router item may not - // be available during routing resulting in a 404. - $this->lock->wait(__FUNCTION__); - } + $this->menuLinkManager->rebuild(); } /** diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 659d6be..f7bd0fe 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -150,6 +150,27 @@ public function resetDefinitions() { * {@inheritdoc} */ public function rebuild(array $definitions) { + if ($this->lock->acquire(__FUNCTION__)) { + $transaction = $this->connection->startTransaction(); + try { + // Ensure the menu links are up to date. + $this->menuLinkManager->rebuild(); + // Ignore any database replicas temporarily. + db_ignore_replica(); + } + catch (\Exception $e) { + $transaction->rollback(); + watchdog_exception('menu', $e); + } + $this->lock->release(__FUNCTION__); + } + else { + // Wait for another request that is already doing this work. + // We choose to block here since otherwise the router item may not + // be available during routing resulting in a 404. + $this->lock->wait(__FUNCTION__); + } + $links = array(); $children = array(); $top_links = array();