Bug #88714

f:link.action does not allow to render a link without a cHash when generating a dynamic route with dynamic arguments (extbase route enhancer)

Added by Denis Mir 14 days ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2019-07-10
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

We are trying to render a dynamic route with the "f:link.action" viewhelper like this:

<f:link.action class="blog__stroy" action="show" extensionName="blog" pluginName="blog" pageUid="2" arguments="{slug: story.slug}" noCacheHash="true" target="_blank">

In this case the "noCacheHash" parameter gets ignored and the link always gets generated with the cHash.

Digging deeper I found that the route cause is the "PageRouter" which does the following in the generateUri method:

// cHash is never considered because cHash is built by this very method.
unset($originalParameters['cHash']);

In the documentation it says:

The requirements section exactly specifies what kind of parameter should be added to that route as regular expression. This way, it is configurable to only allow integer values for e.g. pagination. If the requirements are too loose, a URL signature parameter ("cHash") is added to the end of the URL which cannot be removed.

But what are "too loose requirements"? When looking at the code in the PageRouter there is not evaluation whatsoever it just does:

if ($matchedRoute && $pageRouteResult && !empty($pageRouteResult->getDynamicArguments())) {
            $cacheHash = $this->generateCacheHash($pageId, $pageRouteResult);

            if (!empty($cacheHash)) {
                $queryArguments = $pageRouteResult->getQueryArguments();
                $queryArguments['cHash'] = $cacheHash;
                $uri = $uri->withQuery(http_build_query($queryArguments, '', '&', PHP_QUERY_RFC3986));
            }
        }

So as long as there are dynamic arguments in the route the cHash is enforced. We just don't want and don't need the cHash since we only allow uuids for the dynamic argument part compared against the database. I think this is a common use case which should be supported. Always enforcing the cHash can't be the solution.

Also available in: Atom PDF