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 #1

Updated by Dmitry Dulepov over 5 years ago

  • Related to Bug #87653: cHash error with extbase plugin and routeEnhancer added
Actions #2

Updated by Oliver Hader over 5 years ago

Thanks for the report. The references issue mentions config.defaultGetVars, is that defined in your scenario as well?

Could you please share the URLs you're using for
  • URL generation (e.g. input id=123&tx_plugin_pi1[abc]=234)
  • URL resolving (e.g. /page/plugin/abc-value)

Having according scenarios and examples would allow to create (additional) test cases. Thanks in advance!

Actions #3

Updated by Dmitry Dulepov over 5 years ago

Yes, I independently found that `config.defaultGetVars.L = 0` was set. Even though `L` does not affect cHash, it causes $TSFE->reqCHash to proceed because `L` appears in page's dynamic arguments. That must be the cause of 404s.

So this needs more investigation and correction of the original text.

Actions #4

Updated by Dmitry Dulepov over 5 years ago

  • Subject changed from Remove requireCHashArgumentForActionArguments setting to requireCHashArgumentForActionArguments may cause 404 errors
Actions #5

Updated by Oliver Hader over 5 years ago

Thanks Dmitry, that's good information and narrows down analysis on this behavior. I could try to integrate that scenario to our tests as well...

Actions #6

Updated by Oliver Hader almost 3 years ago

This setting has been dropped in TYPO3 v11.0

Extbase TypoScript option requireCHashArgumentForActionArguments for any plugin

see https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.0/Breaking-91473-DeprecatedFunctionalityRemoved.html

Actions #7

Updated by Oliver Hader almost 3 years ago

Actions #8

Updated by Oliver Hader almost 3 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF