diff --git a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php index f1871089e9..93d8a137bb 100644 --- a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php @@ -285,9 +285,7 @@ public function isTranslatable() { * {@inheritdoc} */ public function hasTranslation($langcode) : bool { - $entity = $this->getEntity(); - return $entity->hasTranslation($langcode) - && Url::fromUri($entity->link->uri)->access(); + return $this->getEntity()->hasTranslation($langcode); } /** diff --git a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTranslationTest.php b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTranslationTest.php index 84a916ac17..cf35704ef3 100644 --- a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTranslationTest.php +++ b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTranslationTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\system\Kernel\Block; +use Drupal\Core\Language\Language; use Drupal\system\Entity\Menu; use Drupal\KernelTests\KernelTestBase; use Drupal\language\Entity\ConfigurableLanguage; @@ -81,7 +82,6 @@ protected function setUp(): void { // Install schemas & config. $this->installConfig(['language']); - $this->installSchema('system', 'sequences'); $this->installEntitySchema('configurable_language'); $this->installEntitySchema('user'); $this->installEntitySchema('menu_link_content'); @@ -115,8 +115,8 @@ public function testMenuBlockTranslation() { $languages = [ 'en' => 'English', 'fr' => 'French', - 'und' => 'Not specified', - 'zxx' => 'Not applicable', + Language::LANGCODE_NOT_SPECIFIED => 'Not specified', + Language::LANGCODE_NOT_APPLICABLE => 'Not applicable', ]; $links = []; foreach ($languages as $langcode => $langname) { @@ -151,8 +151,8 @@ public function testMenuBlockTranslation() { $items = $build['#items'] ?? []; $this->assertArrayHasKey('menu_link_content:' . $links['en']->uuid(), $items); $this->assertArrayNotHasKey('menu_link_content:' . $links['fr']->uuid(), $items); - $this->assertArrayHasKey('menu_link_content:' . $links['und']->uuid(), $items); - $this->assertArrayHasKey('menu_link_content:' . $links['zxx']->uuid(), $items); + $this->assertArrayHasKey('menu_link_content:' . $links[Language::LANGCODE_NOT_SPECIFIED]->uuid(), $items); + $this->assertArrayHasKey('menu_link_content:' . $links[Language::LANGCODE_NOT_APPLICABLE]->uuid(), $items); // Viewing block from French interface should show links which language is // - French @@ -165,8 +165,8 @@ public function testMenuBlockTranslation() { $items = $build['#items'] ?? []; $this->assertArrayNotHasKey('menu_link_content:' . $links['en']->uuid(), $items); $this->assertArrayHasKey('menu_link_content:' . $links['fr']->uuid(), $items); - $this->assertArrayHasKey('menu_link_content:' . $links['und']->uuid(), $items); - $this->assertArrayHasKey('menu_link_content:' . $links['zxx']->uuid(), $items); + $this->assertArrayHasKey('menu_link_content:' . $links[Language::LANGCODE_NOT_SPECIFIED]->uuid(), $items); + $this->assertArrayHasKey('menu_link_content:' . $links[Language::LANGCODE_NOT_APPLICABLE]->uuid(), $items); } }