From b2d34992b2291541c5c168b2281ee182cee76e91 Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Wed, 6 Dec 2017 20:11:39 +0100
Subject: [PATCH] [!!!][BUGFIX] Fluid Widget Links: Do not use cHash by default

When using the widget.link viewhelper, it is not possible to create links
without cHash.

In order to achieve this, cHash is only appended, if "useCacheHash" is
activated (addQueryString is always added, which makes sense due to the
parameters for the link).

As this is a breaking bugfix, it can only go in master.

Resolves: #83244
Resolves: #61960
Releases: master
Change-Id: I1c2dcf159a107188fd744f32de60809d15831162
Reviewed-on: https://review.typo3.org/54967
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
---
 ...tAddCacheHashParameterByDefaultAnymore.rst | 38 +++++++++++++++++++
 .../ViewHelpers/Widget/LinkViewHelper.php     |  2 +
 .../ViewHelpers/Widget/UriViewHelper.php      |  2 +
 3 files changed, 42 insertions(+)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Breaking-83244-FluidWidgetLinksDoNotAddCacheHashParameterByDefaultAnymore.rst

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-83244-FluidWidgetLinksDoNotAddCacheHashParameterByDefaultAnymore.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-83244-FluidWidgetLinksDoNotAddCacheHashParameterByDefaultAnymore.rst
new file mode 100644
index 000000000000..18b59638d16f
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-83244-FluidWidgetLinksDoNotAddCacheHashParameterByDefaultAnymore.rst
@@ -0,0 +1,38 @@
+.. include:: ../../Includes.txt
+
+=======================================================================================
+Breaking: #83244 - Fluid Widget Links do not add cacheHash parameter by default anymore
+=======================================================================================
+
+See :issue:`83244`
+
+Description
+===========
+
+When using links for fluid widgets (like Paginator widgets) it is not possible to disable the cHash calculation.
+
+A new argument "useCacheHash" for the `<f:widget.link>` and the `<f:widget.uri>` ViewHelpers has been added
+to re-enable the previous behaviour.
+
+Additionally, using cHash and addQueryString is counterproductive for deterministic caching purposes,
+thus this combination should not be set by TYPO3 core by default.
+
+
+Impact
+======
+
+Using the `<f:widget.link>` or `<f:widget.uri>` ViewHelper will not generate a cHash anymore.
+
+
+Affected Installations
+======================
+
+Installations using extensions that are built around Fluid widgets.
+
+
+Migration
+=========
+
+None. If necessary, activate the cHash calculation by using the newly introduced Fluid argument "useCacheHash".
+
+.. index:: Fluid, NotScanned
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/LinkViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/LinkViewHelper.php
index d3841630ee60..c74c59df4634 100644
--- a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/LinkViewHelper.php
+++ b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/LinkViewHelper.php
@@ -49,6 +49,7 @@ class LinkViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedVi
         $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
         $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
         $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
+        $this->registerArgument('useCacheHash', 'bool', 'True whether the cache hash should be appended to the URL', false, false);
         $this->registerArgument('addQueryStringMethod', 'string', 'Method to be used for query string');
         $this->registerArgument('action', 'string', 'Target action');
         $this->registerArgument('arguments', 'array', 'Arguments', false, []);
@@ -116,6 +117,7 @@ class LinkViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedVi
         return $uriBuilder->reset()
             ->setArguments([$argumentPrefix => $arguments])
             ->setSection($this->arguments['section'])
+            ->setUseCacheHash($this->arguments['useCacheHash'])
             ->setAddQueryString(true)
             ->setAddQueryStringMethod($this->arguments['addQueryStringMethod'])
             ->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash'])
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/UriViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/UriViewHelper.php
index f67fb33add01..5ad45e4b8b0a 100644
--- a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/UriViewHelper.php
+++ b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/UriViewHelper.php
@@ -44,6 +44,7 @@ class UriViewHelper extends AbstractViewHelper
      */
     public function initializeArguments()
     {
+        $this->registerArgument('useCacheHash', 'bool', 'True whether the cache hash should be appended to the URL', false, false);
         $this->registerArgument('addQueryStringMethod', 'string', 'Method to be used for query string');
         $this->registerArgument('action', 'string', 'Target action');
         $this->registerArgument('arguments', 'array', 'Arguments', false, []);
@@ -113,6 +114,7 @@ class UriViewHelper extends AbstractViewHelper
         return $uriBuilder->reset()
             ->setArguments([$argumentPrefix => $parameters])
             ->setSection($arguments['section'])
+            ->setUseCacheHash($arguments['useCacheHash'])
             ->setAddQueryString(true)
             ->setAddQueryStringMethod($arguments['addQueryStringMethod'])
             ->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash'])
-- 
GitLab