Skip to content
Snippets Groups Projects
Commit 17b0786b authored by Markus Klein's avatar Markus Klein Committed by Christian Eßl
Browse files

[BUGFIX] Do not generate links to unreachable pages

Fix the condition whether a page is linkable in the requested
language or not.

Resolves: #90850
Releases: master, 9.5, 8.7
Change-Id: I720c09cc1f938b5000980bcba20786a5cf41f98d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63946


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarChristian Eßl <indy.essl@gmail.com>
Reviewed-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: default avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: default avatarJosef Glatz <josefglatz@gmail.com>
Reviewed-by: default avatarGuido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: default avatarChristian Eßl <indy.essl@gmail.com>
parent df36be46
No related merge requests found
......@@ -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);
}
}
......
......@@ -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' => ''],
],
],
];
......
......@@ -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'],
],
],
];
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment