diff --git a/typo3/sysext/core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php b/typo3/sysext/core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php index 7935b59054724dc79bf1476b73bbb076d5a23599..3bf2e8739dbd1e9c2a6d2b8d66e39bd186e27c17 100644 --- a/typo3/sysext/core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php +++ b/typo3/sysext/core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php @@ -105,12 +105,22 @@ class PageContentErrorHandler implements PageErrorHandlerInterface return $urlParams['url']; } - $site = $request->getAttribute('site', null); + // Get the site related to the configured error page + $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId((int)$urlParams['pageuid']); + // Fall back to current request for the site if (!$site instanceof Site) { - $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId((int)$urlParams['pageuid']); + $site = $request->getAttribute('site', null); } - $language = $request->getAttribute('language', null); - if (!$language instanceof SiteLanguage || !$language->isEnabled()) { + /** @var SiteLanguage $requestLanguage */ + $requestLanguage = $request->getAttribute('language', null); + // Try to get the current request language from the site that was found above + if ($requestLanguage instanceof SiteLanguage) { + try { + $language = $site->getLanguageById($requestLanguage->getLanguageId()); + } catch (\InvalidArgumentException $e) { + $language = $site->getDefaultLanguage(); + } + } else { $language = $site->getDefaultLanguage(); }