Bug #88136
closedrequireCHashArgumentForActionArguments may cause 404 errors
0%
Description
After the introduction of routing in TYPO3 9.5 there is a major issue with requireCHashArgumentForActionArguments
: if enabled, it causes a page not found error for all configured routes without non-routed parameters.
Here is why it happens.
URLs are generated by `\TYPO3\CMS\Core\Routing\PageRouter::generateUri()` method. This method will unconditionally remove cHash generated by typolink
:
238 // cHash is never considered because cHash is built by this very method. 239 unset($originalParameters['cHash']);
Later the function checks if it needs to add cHash:
305 if ($matchedRoute && $pageRouteResult && !empty($pageRouteResult->getDynamicArguments())) { 306 $cacheHash = $this->generateCacheHash($pageId, $pageRouteResult); 307 308 if (!empty($cacheHash)) { 309 $queryArguments = $pageRouteResult->getQueryArguments(); 310 $queryArguments['cHash'] = $cacheHash; 311 $uri = $uri->withQuery(http_build_query($queryArguments, '', '&', PHP_QUERY_RFC3986)); 312 } 313 }
Those "dynamic arguments" are arguments that are not mapped by any routes. Thus there will be no cHash in the url if all parameters are mapped by routing! Thus if all parameters are mapped by routing and requireCHashArgumentForActionArguments = 1
, there will be a page not found error.
Additional information.
Earlier cHash was always required for proper caching if there are url parameters (see https://typo3.org/article/the-mysteries-of-chash/). Now, after recent change, it is no longer needed because TyposcriptFrontendController
uses routing parameters for cache:
protected function createHashBase($createLockHashBase = false) { ... $hashParameters = [ ... // cHash_array includes dynamic route arguments (if route was resolved) 'cHash' => $this->cHash_array, // additional variation trigger for static routes 'staticRouteArguments' => $this->pageArguments !== null ? $this->pageArguments->getStaticArguments() : null, 'domainStartPage' => $this->domainStartPage ]; ... }
So having requireCHashArgumentForActionArguments
does not make any sense now because with proper routing config this setting will not work.