[BUGFIX] Bind the cHash to the id of the "real" page 24/50624/3
authorHelmut Hummel <info@helhum.io>
Sat, 12 Nov 2016 23:48:56 +0000 (00:48 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Sun, 13 Nov 2016 09:54:07 +0000 (10:54 +0100)
If a link to a mount point or a shortcut is created,
the id argument in the url points to the id of the real page,
where the mount or the shortcut points to.

This is why we need to take the id of the final page
to be hashed and not the one used to generate the link.

We also need to move cHash calculation below shortcut resolving.

Resolves: #78238
Releases: master, 7.6, 6.2
Change-Id: I96c4305c6d769a5851c17d6fdcba3cd7584fc3ec
Reviewed-on: https://review.typo3.org/50624
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index 293d087..6878353 100644 (file)
@@ -6611,16 +6611,6 @@ class ContentObjectRenderer
                     if ($addQueryParams === '&' || $addQueryParams[0] !== '&') {
                         $addQueryParams = '';
                     }
-                    if ($conf['useCacheHash']) {
-                        $params = $tsfe->linkVars . $addQueryParams . '&id=' . $linkParameter;
-                        if (trim($params, '& ') != '') {
-                            /** @var $cacheHash CacheHashCalculator */
-                            $cacheHash = GeneralUtility::makeInstance(CacheHashCalculator::class);
-                            $cHash = $cacheHash->generateForParameters($params);
-                            $addQueryParams .= $cHash ? '&cHash=' . $cHash : '';
-                        }
-                        unset($params);
-                    }
                     $targetDomain = '';
                     $currentDomain = (string)$this->getEnvironmentVariable('HTTP_HOST');
                     // Mount pages are always local and never link to another domain
@@ -6662,6 +6652,16 @@ class ContentObjectRenderer
                             $targetDomain = '';
                         }
                     }
+                    if ($conf['useCacheHash']) {
+                        $params = $tsfe->linkVars . $addQueryParams . '&id=' . $page['uid'];
+                        if (trim($params, '& ') != '') {
+                            /** @var $cacheHash CacheHashCalculator */
+                            $cacheHash = GeneralUtility::makeInstance(CacheHashCalculator::class);
+                            $cHash = $cacheHash->generateForParameters($params);
+                            $addQueryParams .= $cHash ? '&cHash=' . $cHash : '';
+                        }
+                        unset($params);
+                    }
                     $absoluteUrlScheme = 'http';
                     // URL shall be absolute:
                     if (isset($conf['forceAbsoluteUrl']) && $conf['forceAbsoluteUrl'] || $page['url_scheme'] > 0) {