From da0e0152e75b2da72873f1d0afb748ac770a44cc Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Mon, 2 May 2022 16:39:23 +0200
Subject: [PATCH] [TASK] Avoid additional checks in TSFE when resolving a page

When TSFE is fetching the $page record from PageRepository,
it checks the $TSFE->id parameter, which was originally
the GET parameter. In TYPO3 v9, when "pages_language_overlay"
was merged into "pages", an intermediate step was added
to access translated pages via the GET parameter as well.

This concept however was never needed, as the page ID of the
default language was always resolved with Site Handling
already in the PageRouter.

The double-check in TSFE can be removed, as site handling has
taken over since TYPO3 v10, and was never accessed since
its introduction in TYPO3 v9 (mainly because
the code was added with the migration of "pages_language_overlay"
into "pages" into TYPO3 v9.0, whereas site handling was only added
in TYPO3 v9.2+).

Resolves: #97533
Releases: main
Change-Id: I290200f90b4d23589a4f7aec33a0516ecfab7739
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74500
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Benjamin Franzke <bfr@qbus.de>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Benjamin Franzke <bfr@qbus.de>
---
 .../TypoScriptFrontendController.php          | 21 +------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
index ed65d410066a..139986a24cc2 100644
--- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
+++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
@@ -738,7 +738,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
     protected function getPageAndRootline(ServerRequestInterface $request)
     {
         $requestedPageRowWithoutGroupCheck = [];
-        $this->resolveTranslatedPageId();
+        $this->page = $this->sys_page->getPage($this->id);
         if (empty($this->page)) {
             // If no page, we try to find the page above in the rootLine.
             // Page is 'not found' in case the id itself was not an accessible page. code 1
@@ -902,25 +902,6 @@ class TypoScriptFrontendController implements LoggerAwareInterface
         }
     }
 
-    /**
-     * If $this->id contains a translated page record, this needs to be resolved to the default language
-     * in order for all rootline functionality and access restrictions to be in place further on.
-     *
-     * Additionally, if a translated page is found, LanguageAspect is set as well.
-     */
-    protected function resolveTranslatedPageId()
-    {
-        $this->page = $this->sys_page->getPage($this->id);
-        // Accessed a default language page record, nothing to resolve
-        if (empty($this->page) || (int)$this->page[$GLOBALS['TCA']['pages']['ctrl']['languageField']] === 0) {
-            return;
-        }
-        $languageId = (int)$this->page[$GLOBALS['TCA']['pages']['ctrl']['languageField']];
-        $this->page = $this->sys_page->getPage($this->page[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']]);
-        $this->context->setAspect('language', GeneralUtility::makeInstance(LanguageAspect::class, $languageId));
-        $this->id = (int)$this->page['uid'];
-    }
-
     /**
      * Checks if visibility of the page is blocked upwards in the root line.
      *
-- 
GitLab