Closed aWuttig closed 8 years ago
That's not right.
Firsts, recent realurl version does not add cache entries in the decoder. If it does, you are not using the latest version and your report cannot be accepted.
Secondly, any links created by the encoder must have their own cHash before they come to realurl. If they don't, than it is a problem of your plugin, typoscript, etc.
So just another question. Is it possible to configure realurl in a way that it ignores parameters like utm_source but also transfer them to typo3?
Depends on what you mean by "realurl ignores the parameter". Realurl does not do anything with parameters if you do not configure it.
Realurl work is quite simple to describe:
$_GET
, ignore what is already in $_GET
So realurl does not know about or do anything with utm_*
parameters. More, TYPO3 already has config that ignores these parameters when calculating cHash. So they should not affect cHash at all unless you did something that unsets default TYPO3 configuration.
I have the same behavior on my own extension. Any kind of additional get-parameter on the url of the show action will display a "random" single view from the cache. I do some further investigation.
@sneopu Google for cHash typo3
.
Hi, I have the same problem with parameters like utm_source even the parameter is listed in $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters']. The Problem is, that realurl make no use of $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'] by lookup the speaking Url in the Cache. I can provide the following solution:
typo3conf/ext/realurl/Classes/Decoder/UrlDecoder.php
/**
* Gets the entry from cache.
*
* @param string $speakingUrl
* @return UrlCacheEntry|null
*/
protected function getFromUrlCache($speakingUrl) {
/* exclude parameter from specking url if the parameter match ['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'] */
$speakingUrl = $this->removeExludedParametersFromUrl($speakingUrl);
return $this->cache->getUrlFromCacheBySpeakingUrl($this->rootPageId, $speakingUrl, $this->detectedLanguageId);
}
/**
* remove all get parameters from url if they are listed as exclude
* so getFromUrlCache is able to find the corresponding record
*
* @param $speakingUrl
* @return string
*/
private function removeExludedParametersFromUrl($speakingUrl){
$cleanedUrl = $speakingUrl;
$splittedUrl = explode('?', $speakingUrl);
if(is_array($splittedUrl)) {
$getParams = explode('&',$splittedUrl[1]);
$excludeParams = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'], TRUE);
$tempParams = $getParams;
foreach ($excludeParams as $excludeParam) {
$i = 0;
foreach ($getParams as $getParam) {
if (strpos($getParam, $excludeParam) == 0) {
unset($tempParams[$i]);
}
$i++;
}
}
$cleanedUrl = $splittedUrl[0] . implode('&', $tempParams);
}
return $cleanedUrl;
}
I'm not sure if this is the right way. I'm looking forward to get your feedback.
As @dtondera reported using a get-parameter which is listed cHashExcludedParameters (for example utm_source) leads to uncached content (or 404 if pageNotFoundOnCHashError=true) instead of getting the cached version without the excluded parameters. The workaround which he provided seems to work in my test, but don't now if it is the way to go.
@dmitryd We got the same problem here, almost all of our systems are affected, since we are relying on utm_source parameters and similar in newsletter campaign tracking. The suggested fix of @dtondera seems to work for us. 👍 Can you please have a look at it?
i've opened for 2 weeks ago an issue about this https://github.com/dmitryd/typo3-realurl/issues/287. In my case removing the following lines from my configuration helped:
array( 'GETvar' => 'tx_news_pi1[action]', 'valueMap' => array( 'detail' => '', ), 'noMatch' => 'bypass' ), array( 'GETvar' => 'tx_news_pi1[controller]', 'valueMap' => array( 'News' => '', ), 'noMatch' => 'bypass' ),
but this is not a solution since the urls change. I have then implemented a similar change to what @dtondera posted.
One note: using cHashExcludedParameters
will not be right here. You may have both cached and un-cached plugins with URL parameters on the same page. In such case you would want to add URL parameters for un-cached plugin to cHashExcludedParameters
but still have them mapped in to postVars, etc. So it needs a separate configuration option.
We use the news extension and have a realurl_conf for the fixedPostVars:
When we try to append the ?utm_source=foo&utm_medium=bar parameters to the speakingurl, realurl is not able to find this within cache and creates a new cache entry which leads to a missing cHash parameter which then leads to wrong content for the called URL.