Project

General

Profile

Actions

Bug #88136

closed

requireCHashArgumentForActionArguments may cause 404 errors

Added by Dmitry Dulepov over 5 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2019-04-11
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

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.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #87653: cHash error with extbase plugin and routeEnhancerClosed2019-02-05

Actions
Related to TYPO3 Core - Task #91522: Remove cHash optionsClosedBenni Mack2020-05-29

Actions
Actions

Also available in: Atom PDF