[!!!][BUGFIX] Skip cache hash for URIs to non-cacheable actions
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Mvc / Web / Routing / UriBuilder.php
index aecdecd..c67bc98 100644 (file)
@@ -510,6 +510,9 @@ class UriBuilder {
                if ($pluginName === NULL) {
                        $pluginName = $this->request->getPluginName();
                }
+
+               $this->disableCacheHashForNonCacheableAction($controllerArguments);
+
                if ($this->environmentService->isEnvironmentInFrontendMode() && $this->configurationManager->isFeatureEnabled('skipDefaultArguments')) {
                        $controllerArguments = $this->removeDefaultControllerAndAction($controllerArguments, $extensionName, $pluginName);
                }
@@ -530,6 +533,25 @@ class UriBuilder {
        }
 
        /**
+        * Disable cache hash if the action is not cacheable
+        * and pointed to from an already uncached request
+        *
+        * @param array $controllerArguments the current controller arguments
+        * @return void
+        */
+       protected function disableCacheHashForNonCacheableAction(array $controllerArguments) {
+               if (isset($controllerArguments['action']) && $this->getUseCacheHash()) {
+                       $actionIsCacheable = $this->extensionService->isActionCacheable(
+                               NULL,
+                               NULL,
+                               $controllerArguments['controller'],
+                               $controllerArguments['action']
+                       );
+                       $this->setUseCacheHash($this->request->isCached() || $actionIsCacheable);
+               }
+       }
+
+       /**
         * This removes controller and/or action arguments from given controllerArguments
         * if they are equal to the default controller/action of the target plugin.
         * Note: This is only active in FE mode and if feature "skipDefaultArguments" is enabled