2 declare(strict_types = 1);
19 use Psr\Http\Message\ResponseInterface;
20 use Psr\Http\Message\ServerRequestInterface;
21 use Psr\Http\Server\MiddlewareInterface;
22 use Psr\Http\Server\RequestHandlerInterface;
23 use Psr\Log\LoggerAwareInterface;
24 use Psr\Log\LoggerAwareTrait;
60 $this->cacheHashCalculator = GeneralUtility::makeInstance(CacheHashCalculator::class);
70 public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
72 $pageNotFoundOnValidationError = (bool)(
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'pageNotFoundOnCHashError'] ??
true);
73 $pageArguments = $request->getAttribute(
'routing',
null);
74 if ($this->controller->no_cache && !$pageNotFoundOnValidationError) {
79 $queryParams = $pageArguments->getDynamicArguments();
81 $queryParams = $request->getQueryParams();
86 if ($this->controller->cHash && empty($this->controller->cHash_array)) {
87 $uri = $request->getUri();
88 unset($queryParams[
'cHash']);
92 return GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction(
94 'Request parameters could not be validated (&cHash comparison failed)',
99 return $handler->handle($request);
115 if ($this->controller->cHash !==
'') {
117 $queryParams[
'id'] = $this->controller->id;
119 $this->controller->cHash_array = $relevantParameters;
121 if (empty($relevantParameters)) {
122 $this->logger->notice(
'The incoming cHash "' . $this->controller->cHash .
'" is given but not needed. cHash is unset');
125 $calculatedCacheHash = $this->cacheHashCalculator->calculateCacheHash($relevantParameters);
126 if (!hash_equals($calculatedCacheHash, $this->controller->cHash)) {
128 if ($pageNotFoundOnCacheHashError) {
131 $this->controller->no_cache =
true;
132 $this->
getTimeTracker()->
setTSlogMessage(
'The incoming cHash "' . $this->controller->cHash .
'" and calculated cHash "' . $calculatedCacheHash .
'" did not match, so caching was disabled. The fieldlist used was "' . implode(
',', array_keys($this->controller->cHash_array)) .
'"', 2);
137 $this->controller->reqCHash();
147 return GeneralUtility::makeInstance(TimeTracker::class);