Bug #24667
closedreqCHash should only look at GET vars
0%
Description
tslib_fe::reqCHash currently triggers the error "Request parameters could not be validated (&cHash empty)" whenever GET or POST vars for a plugin are present and cHash is not submitted.
I think it would make more sense only to look for presence of GET variables, since only they contribute to cHash anyway.
This behavior may be intentional, since the error of course only occurs if pageNotFoundOnCHashError is enabled. Otherwise it simply disables caching whenever a POST request is processed - which does make sense, I admit, but should probably be handled directly.
See below for an example where the current behavior became a problem for me. (I actually think it did not occur before updating from Typo3 4.3 to 4.4, but I can't say for sure).
I have a class derived from tslib_pibase that usually displays cacheable pages according to submitted GET values. I hence use cHash and have pi_checkCHash enabled, so that no double entries are generated if a user simply deletes cHash from the link. I have pageNotFoundOnCHashError enabled, so that users and search engines are not even tempted to generate different links to the same content.
However, my plugin also has a small search form and can react to POST requests (upon which it calls set_no_cache(), to tell the system this is only a one-time output).
This always resulted in the named error for me, whenever a POST request was sent, since of course it did not contain a cHash value.
Since pi_checkCHash is evaluated right in the constcuctor of tslib_pibase, I had no other solution to the problem other than this:
function _construct(){
if (t3lib_div::_POST($this->prefixId)) $this->pi_checkCHash = true;
parent::_construct();
}
(issue imported from #M17148)