[BUGFIX] Check if language is accessible before uri generation 12/60212/9
authorJonas Schwabe <jonas.schwabe@eyeworkers.de>
Fri, 8 Mar 2019 14:59:04 +0000 (15:59 +0100)
committerDaniel Goerz <daniel.goerz@posteo.de>
Wed, 17 Apr 2019 15:19:06 +0000 (17:19 +0200)
Sites with error handling were not rendering the correct page for
disabled languages because an inaccessible language was used
internally.

Resolves: #87865
Releases: master, 9.5
Change-Id: I8f6219d742c74359e0009085711f5452dc139f40
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60212
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Jonas Schwabe <jonas.schwabe@eyeworkers.de>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Jonas Schwabe <jonas.schwabe@eyeworkers.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
typo3/sysext/core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php

index 01f0002..24bc35f 100644 (file)
@@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\LinkHandling\LinkService;
 use TYPO3\CMS\Core\Routing\InvalidRouteArgumentsException;
 use TYPO3\CMS\Core\Site\Entity\Site;
+use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -107,10 +108,14 @@ class PageContentErrorHandler implements PageErrorHandlerInterface
         if (!$site instanceof Site) {
             $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId((int)$urlParams['pageuid']);
         }
+        $language = $request->getAttribute('language', null);
+        if (!$language instanceof SiteLanguage || !$language->isEnabled()) {
+            $language = $site->getDefaultLanguage();
+        }
         // Build Url
         return (string)$site->getRouter()->generateUri(
             (int)$urlParams['pageuid'],
-            ['_language' => $request->getAttribute('language', null)]
+            ['_language' => $language]
         );
     }
 }