diff -u b/core/lib/Drupal/Core/Menu/MenuLinkTree.php b/core/lib/Drupal/Core/Menu/MenuLinkTree.php --- b/core/lib/Drupal/Core/Menu/MenuLinkTree.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkTree.php @@ -936,6 +936,11 @@ * The menu tree you wish to operate on. */ protected function checkAccess(&$tree) { + $this->doCheckAccess($tree); + $this->sortCheckAccess($tree); + } + + protected function doCheckAccess(&$tree) { $new_tree = array(); foreach ($tree as $key => $v) { $definition = $tree[$key]['definition']; @@ -946,15 +951,27 @@ if ($instance) { $tree[$key]['link'] = $instance; if ($tree[$key]['below']) { - $this->checkAccess($tree[$key]['below']); + $this->doCheckAccess($tree[$key]['below']); } unset($tree[$key]['definition']); - // The weights are made a uniform 5 digits by adding 50000 as an offset. - // After $this->menuLinkTranslate(), $item['title'] has the localized - // link title. Adding the plugin id to the end of the index insures that - // it is unique. - $new_tree[(50000 + $instance->getWeight()) . ' ' . $instance->getTitle() . ' ' . $instance->getPluginId()] = $tree[$key]; + $new_tree[$instance->getPluginId()] = $tree[$key]; + } + } + $tree = $new_tree; + } + + protected function sortCheckAccess(&$tree) { + $new_tree = array(); + foreach ($tree as $key => $v) { + if ($tree[$key]['below']) { + $this->sortCheckAccess($tree[$key]['below']); } + $instance = $tree[$key]['link']; + // The weights are made a uniform 5 digits by adding 50000 as an offset. + // After $this->menuLinkTranslate(), $item['title'] has the localized + // link title. Adding the plugin id to the end of the index insures that + // it is unique. + $new_tree[(50000 + $instance->getWeight()) . ' ' . $instance->getTitle() . ' ' . $instance->getPluginId()] = $tree[$key]; } // Sort siblings in the tree based on the weights and localized titles. ksort($new_tree); diff -u b/core/modules/menu_link_content/lib/Drupal/menu_link_content/Entity/MenuLinkContent.php b/core/modules/menu_link_content/lib/Drupal/menu_link_content/Entity/MenuLinkContent.php --- b/core/modules/menu_link_content/lib/Drupal/menu_link_content/Entity/MenuLinkContent.php +++ b/core/modules/menu_link_content/lib/Drupal/menu_link_content/Entity/MenuLinkContent.php @@ -28,7 +28,6 @@ * } * }, * admin_permission = "administer menu", - * static_cache = FALSE, * base_table = "menu_link_content", * data_table = "menu_link_content_data", * fieldable = TRUE, diff -u b/core/modules/menu_link_content/lib/Drupal/menu_link_content/Plugin/Menu/MenuLinkContent.php b/core/modules/menu_link_content/lib/Drupal/menu_link_content/Plugin/Menu/MenuLinkContent.php --- b/core/modules/menu_link_content/lib/Drupal/menu_link_content/Plugin/Menu/MenuLinkContent.php +++ b/core/modules/menu_link_content/lib/Drupal/menu_link_content/Plugin/Menu/MenuLinkContent.php @@ -18,6 +18,8 @@ */ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInterface { + protected static $entityIdsToLoad = array(); + /** * Defines all overrideable values. * @@ -66,6 +68,11 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); + if (!empty($this->pluginDefinition['metadata']['entity_id'])) { + $entity_id = $this->pluginDefinition['metadata']['entity_id']; + static::$entityIdsToLoad[$entity_id] = $entity_id; + } + $this->entityManager = $entity_manager; } @@ -90,7 +97,11 @@ if (empty($this->entity)) { $storage = $this->entityManager->getStorage('menu_link_content'); if (!empty($this->pluginDefinition['metadata']['entity_id'])) { - $this->entity = $storage->load($this->pluginDefinition['metadata']['entity_id']); + $entity_id = $this->pluginDefinition['metadata']['entity_id']; + static::$entityIdsToLoad[$entity_id] = $entity_id; + $entities = $storage->loadMultiple(array_values(static::$entityIdsToLoad)); + $this->entity = isset($entities[$entity_id]) ? $entities[$entity_id] : NULL; + static::$entityIdsToLoad = array(); } else { // Fallback to the loading by the uuid.