diff --git a/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php b/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php index 8afb4ca43cf12e93ad6ee7d1ced362e300a217df..864bf12f4f382b6608f2dceb7ff10ca8d5b46224 100644 --- a/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php +++ b/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php @@ -196,12 +196,14 @@ class PageLinkBuilder extends AbstractTypolinkBuilder } // Check if the target page can be access depending on l18n_cfg if (!$tsfe->sys_page->isPageSuitableForLanguage($page, $languageAspect)) { - $languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'] ?? null; - $languageOfPageRecord = (int)($page[$languageField] ?? 0); - if ($languageOfPageRecord === 0 && GeneralUtility::hideIfDefaultLanguage($page['l18n_cfg'])) { + if ($siteLanguageOfTargetPage->getLanguageId() === 0 && GeneralUtility::hideIfDefaultLanguage($page['l18n_cfg'])) { throw new UnableToLinkException('Default language of page "' . $linkDetails['typoLinkParameter'] . '" is hidden, so "' . $linkText . '" was not linked.', 1551621985, null, $linkText); } - if ($languageOfPageRecord > 0 && !isset($page['_PAGES_OVERLAY']) && GeneralUtility::hideIfNotTranslated($page['l18n_cfg'])) { + // If the requested language is not the default language and the page has no overlay for this language + // generating a link would cause a 404 error when using this like if one of those conditions apply: + // - The page is set to be hidden if it is not translated (evaluated in TSFE) + // - The site configuration has a "strict" fallback set (evaluated in the Router - very early) + if ($siteLanguageOfTargetPage->getLanguageId() > 0 && !isset($page['_PAGES_OVERLAY']) && (GeneralUtility::hideIfNotTranslated($page['l18n_cfg']) || $siteLanguageOfTargetPage->getFallbackType() === 'strict')) { throw new UnableToLinkException('Fallback to default language of page "' . $linkDetails['typoLinkParameter'] . '" is disabled, so "' . $linkText . '" was not linked.', 1551621996, null, $linkText); } } diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioDTest.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioDTest.php index 684cb8ac26b64412198560c2636caa4262cc0602..d7439c8e6e9afa079a3e5665b21e2668103cf273 100644 --- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioDTest.php +++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioDTest.php @@ -167,8 +167,7 @@ class ScenarioDTest extends AbstractLocalizedPagesTestCase 'menu' => [ ['title' => 'DE-CH: Ãœber uns', 'link' => '/de-ch/ueber-uns'], ['title' => 'DE-CH: Produkte', 'link' => '/de-ch/produkte'], - // FIXME: Page "EN: Shortcut to welcome" must to be rendered in menu, needs a refactored menu generation - ['title' => 'EN: Shortcut to welcome', 'link' => '/de-ch/hello'], + ['title' => 'EN: Shortcut to welcome', 'link' => ''], ], ], ]; diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioETest.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioETest.php index 601b0af3b1600098aec0cb24d024e36eb59d7c06..1fce95ca7808ccccc7bdd74d015c679be83dfcb0 100644 --- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioETest.php +++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioETest.php @@ -152,8 +152,7 @@ class ScenarioETest extends AbstractLocalizedPagesTestCase 'menu' => [ ['title' => 'DE: Ãœber uns', 'link' => '/de-ch/ueber-uns'], ['title' => 'DE: Produkte', 'link' => '/de-ch/produkte'], - // FIXME: Page "EN: Shortcut to welcome" must to be rendered in menu, needs a refactored menu generation - ['title' => 'EN: Shortcut to welcome', 'link' => ''], + ['title' => 'EN: Shortcut to welcome', 'link' => '/de-ch/hello'], ], ], [ @@ -161,8 +160,7 @@ class ScenarioETest extends AbstractLocalizedPagesTestCase 'menu' => [ ['title' => 'DE: Ãœber uns', 'link' => '/de-ch/ueber-uns'], ['title' => 'DE: Produkte', 'link' => '/de-ch/produkte'], - // FIXME: Page "EN: Shortcut to welcome" must to be rendered in menu, needs a refactored menu generation - ['title' => 'EN: Shortcut to welcome', 'link' => ''], + ['title' => 'EN: Shortcut to welcome', 'link' => '/de-ch/hello'], ], ], ];