[BUGFIX] Evaluate config.defaultGetVars in middleware 66/58266/3
authorBenni Mack <benni@typo3.org>
Thu, 13 Sep 2018 11:41:29 +0000 (13:41 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 13 Sep 2018 13:05:07 +0000 (15:05 +0200)
The config.defaultGetVars is executed and $_GET is modified,
but not the middleware where this method is called.

In order to also modify the middleware's request object, the
option config.defaultGetVars is also evaluted again in the PSR-15
middleware.

Resolves: #86241
Related: #86046
Releases: master
Change-Id: I2238d93b4974a40b2228c099cef7c8a04bd6cf74
Reviewed-on: https://review.typo3.org/58266
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Daniel Sattler <sattler@b13.de>
Tested-by: Daniel Sattler <sattler@b13.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php

index 370f1f7..860835d 100644 (file)
@@ -2591,6 +2591,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
             $this->set_no_cache('config.no_cache is set');
         }
         // Merge GET with defaultGetVars
+        // Please note that this code will get removed in TYPO3 v10.0 as it is done in the PSR-15 middleware.
         if (!empty($this->config['config']['defaultGetVars.'])) {
             $modifiedGetVars = GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']);
             ArrayUtility::mergeRecursiveWithOverrule($modifiedGetVars, GeneralUtility::_GET());
index dd57e6c..ff6388a 100644 (file)
@@ -21,6 +21,7 @@ use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Server\MiddlewareInterface;
 use Psr\Http\Server\RequestHandlerInterface as PsrRequestHandlerInterface;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 
@@ -64,6 +65,19 @@ class PrepareTypoScriptFrontendRendering implements MiddlewareInterface
         // Get config if not already gotten
         // After this, we should have a valid config-array ready
         $this->controller->getConfigArray();
+
+        // Merge Query Parameters with config.defaultGetVars
+        // This is done in getConfigArray as well, but does not override the current middleware request object
+        // Since we want to stay in sync with this, the option needs to be set as well.
+        if (!empty($this->controller->config['config']['defaultGetVars.'] ?? null)) {
+            $modifiedGetVars = GeneralUtility::removeDotsFromTS($this->controller->config['config']['defaultGetVars.']);
+            if (!empty($request->getQueryParams())) {
+                ArrayUtility::mergeRecursiveWithOverrule($modifiedGetVars, $request->getQueryParams());
+            }
+            $request = $request->withQueryParams($modifiedGetVars);
+            $GLOBALS['TYPO3_REQUEST'] = $request;
+        }
+
         // Setting language and locale
         $this->timeTracker->push('Setting language and locale');
         $this->controller->settingLanguage();