diff --git a/typo3/sysext/core/Classes/Routing/PageArguments.php b/typo3/sysext/core/Classes/Routing/PageArguments.php index 58e12f5ec2ef38980070c825e0c93202e5067f46..996f4f696bd01679b6ec71ea2f6e2066d803c4fd 100644 --- a/typo3/sysext/core/Classes/Routing/PageArguments.php +++ b/typo3/sysext/core/Classes/Routing/PageArguments.php @@ -144,6 +144,7 @@ class PageArguments implements RouteResultInterface /** * @param array $queryArguments * @return static + * @internal this is internal due to the issue that a PageArgument should not be modified, but must be within TYPO3 Core currently. */ public function withQueryArguments(array $queryArguments): self { diff --git a/typo3/sysext/frontend/Classes/Middleware/PageArgumentValidator.php b/typo3/sysext/frontend/Classes/Middleware/PageArgumentValidator.php index f88dd4b5755ed48d009cf07ffec0dc43767dbf33..7f0a18c7a6e9521e9ecc4df5304538b3b243e18c 100644 --- a/typo3/sysext/frontend/Classes/Middleware/PageArgumentValidator.php +++ b/typo3/sysext/frontend/Classes/Middleware/PageArgumentValidator.php @@ -66,9 +66,6 @@ class PageArgumentValidator implements MiddlewareInterface { $pageNotFoundOnValidationError = (bool)($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFoundOnCHashError'] ?? true); $pageArguments = $request->getAttribute('routing', null); - if ($pageArguments instanceof PageArguments) { - $this->controller->setPageArguments($pageArguments); - } if ($this->controller->no_cache && !$pageNotFoundOnValidationError) { // No need to test anything if caching was already disabled. } else { diff --git a/typo3/sysext/frontend/Classes/Middleware/PageResolver.php b/typo3/sysext/frontend/Classes/Middleware/PageResolver.php index bd48da61dc81a809255927d3633342e9c93794a3..34018af9b5499d7e218e885582b052b1fce9df1d 100644 --- a/typo3/sysext/frontend/Classes/Middleware/PageResolver.php +++ b/typo3/sysext/frontend/Classes/Middleware/PageResolver.php @@ -89,7 +89,7 @@ class PageResolver implements MiddlewareInterface $requestId = (string)($request->getQueryParams()['id'] ?? ''); if (!empty($requestId) && !empty($page = $this->resolvePageId($requestId))) { // Legacy URIs (?id=12345) takes precedence, not matter if a route is given - $routeResult = new PageArguments( + $pageArguments = new PageArguments( (int)($page['l10n_parent'] ?: $page['uid']), [], [], @@ -97,9 +97,9 @@ class PageResolver implements MiddlewareInterface ); } else { // Check for the route - $routeResult = $site->getRouter()->matchRequest($request, $previousResult); + $pageArguments = $site->getRouter()->matchRequest($request, $previousResult); } - if ($routeResult === null || !$routeResult->getPageId()) { + if ($pageArguments === null || !$pageArguments->getPageId()) { return GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( $request, 'The requested page does not exist', @@ -107,16 +107,23 @@ class PageResolver implements MiddlewareInterface ); } - $this->controller->id = $routeResult->getPageId(); - $request = $request->withAttribute('routing', $routeResult); + $this->controller->id = $pageArguments->getPageId(); + $this->controller->type = $pageArguments->getArguments()['type'] ?? $this->controller->type; + $request = $request->withAttribute('routing', $pageArguments); // stop in case arguments are dirty (=defined twice in route and GET query parameters) - if ($routeResult->areDirty()) { + if ($pageArguments->areDirty()) { return GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( $request, 'The requested URL is not distinct', ['code' => PageAccessFailureReasons::PAGE_NOT_FOUND] ); } + + // merge the PageArguments with the request query parameters + $queryParams = array_replace_recursive($request->getQueryParams(), $pageArguments->getArguments()); + $request = $request->withQueryParams($queryParams); + $this->controller->setPageArguments($pageArguments); + // At this point, we later get further route modifiers // for bw-compat we update $GLOBALS[TYPO3_REQUEST] to be used later in TSFE. $GLOBALS['TYPO3_REQUEST'] = $request; diff --git a/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php b/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php index 7987b935f0fd6a044f5440da8bb9866f65b9a7be..b419c737d87336edaa7f9b0131f1b80e7b35b90a 100644 --- a/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php +++ b/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php @@ -77,6 +77,7 @@ class PrepareTypoScriptFrontendRendering implements MiddlewareInterface $modifiedGetVars = GeneralUtility::removeDotsFromTS($this->controller->config['config']['defaultGetVars.']); if ($pageArguments instanceof PageArguments) { $pageArguments = $pageArguments->withQueryArguments($modifiedGetVars); + $this->controller->setPageArguments($pageArguments); $request = $request->withAttribute('routing', $pageArguments); } if (!empty($request->getQueryParams())) { @@ -85,12 +86,6 @@ class PrepareTypoScriptFrontendRendering implements MiddlewareInterface $request = $request->withQueryParams($modifiedGetVars); $GLOBALS['TYPO3_REQUEST'] = $request; } - // Populate internal route query arguments to super global $_GET - if ($pageArguments instanceof PageArguments) { - $_GET = $pageArguments->getArguments(); - $GLOBALS['HTTP_GET_VARS'] = $pageArguments->getArguments(); - $this->controller->setPageArguments($pageArguments); - } // Setting language and locale $this->timeTracker->push('Setting language and locale');