diff -u b/core/modules/menu_link_content/src/MenuLinkContentAccessControlHandler.php b/core/modules/menu_link_content/src/MenuLinkContentAccessControlHandler.php --- b/core/modules/menu_link_content/src/MenuLinkContentAccessControlHandler.php +++ b/core/modules/menu_link_content/src/MenuLinkContentAccessControlHandler.php @@ -53,16 +53,16 @@ if ($account->hasPermission('administer menu')) { return AccessResult::allowed()->cachePerPermissions()->addCacheableDependency($entity); } - // If menu link is internal, and user has access, grant view access to menu link. + // If menu link is internal, and user has access, + // grant view access to menu link. + /** @var \Drupal\menu_link_content\MenuLinkContentInterface $entity */ if (($url_object = $entity->getUrlObject()) && ($url_object->isRouted())) { $link_access = $this->accessManager->checkNamedRoute($url_object->getRouteName(), $url_object->getRouteParameters(), $account, TRUE); - if ($link_access->isAllowed()) { - return AccessResult::allowed()->cachePerPermissions()->addCacheableDependency($entity); - } + return AccessResult::allowedIf($link_access->isAllowed())->cachePerPermissions()->addCacheableDependency($entity); } // Grant view access to external links. - elseif ($url_object->isExternal()) { - return AccessResult::allowed()->cachePerPermissions()->addCacheableDependency($entity); + else { + return AccessResult::allowedIf($url_object->isExternal())->cachePerPermissions()->addCacheableDependency($entity); } case 'update': @@ -84,6 +84,9 @@ case 'delete': return AccessResult::allowedIf(!$entity->isNew() && $account->hasPermission('administer menu'))->cachePerPermissions()->addCacheableDependency($entity); + + default: + return AccessResult::neutral(); } }