Commit e131831e authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[BUGFIX] Handle disabled default language in PageContentErrorHandler

The SiteInterface provides the "getDefaultLanguage()"
method, which will always return the first configured
language - usually L=0. However, this language might
be disabled, which means, it should not be visible
in frontend context.

The PageContentErrorHandler therefore now tries
to fetch the first enabled language, in case the
requested language id does not exist in the current
site and the sites' default language is disabled.

Resolves: #99530
Releases: main, 11.5
Change-Id: Ib02cbd8f01a4fc1a69be46ad2015e8863553fae0
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77538


Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent 36177e36
......@@ -157,6 +157,18 @@ class PageContentErrorHandler implements PageErrorHandlerInterface
$language = $site->getDefaultLanguage();
}
// Requested language or default language is disabled in current site => Fetch first "enabled" language
if (!$language->isEnabled()) {
$enabledLanguages = $site->getLanguages();
if ($enabledLanguages === []) {
throw new \RuntimeException(
'Site ' . $site->getIdentifier() . ' does not define any enabled language.',
1674487171
);
}
$language = reset($enabledLanguages);
}
// Build Url
$uri = $site->getRouter()->generateUri(
(int)$urlParams['pageuid'],
......
Supports Markdown
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