Bug #81293

cacheHash fails to be generated because of missing id although id is present in request-string

Added by David Bascom over 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
-- undefined --
Assignee:
Category:
Extbase
Target version:
-
Start date:
2017-05-22
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

An error #1467983513: ID parameter needs to be passed for the cHash calculation! is thrown in certain cases although id is present in GET-query (see screenshot for example).

Reason: In sysext/extbase/Classes/Mvc/Web/CacheHashEnforcer.php->enforceForRequest() on line 66 this function is called:

$this->cacheHashCalculator->getRelevantParameters(
    http_build_query($parameters)
)

http_build_query() builds the query using the urlencoded & instead of a simple "&". The query-string is then passed to sysext/frontend/Classes/Page/CacheHashCalculator.php->splitQueryStringToArray() which uses an simple & to explode the parameters again: explode('&', ...) and convert them back to an associative array:

     $parameters = array_filter(explode('&', ltrim($queryString, '?')));

This leads to an error, because the id-parameter can not be extracted correctly in some cases.
To solve the problem, the line in sysext/extbase/Classes/Mvc/Web/CacheHashEnforcer.php->enforceForRequest() needs to be corrected to:

$this->cacheHashCalculator->getRelevantParameters(
    http_build_query($parameters, '', '&')
)

Files

Bildschirmfoto 2017-05-22 um 11.46.39.png (195 KB) Bildschirmfoto 2017-05-22 um 11.46.39.png David Bascom, 2017-05-22 12:01
exception.jpg (170 KB) exception.jpg Carsten Falkenberg, 2017-05-23 16:42

Related issues

Related to TYPO3 Core - Bug #78002: Require cHash for cached plugin actions in ExtbaseClosed2016-09-20

Actions
Related to TYPO3 Core - Task #81366: Make sure all http_build_query() calls use a defined separatorClosedMarkus Klein2017-05-29

Actions
Has duplicate TYPO3 Core - Bug #81565: ID parameter needs to be passed for the cHash calculation!Closed2017-06-13

Actions
#1

Updated by Markus Klein over 4 years ago

  • Related to Bug #78002: Require cHash for cached plugin actions in Extbase added
#2

Updated by Markus Klein over 4 years ago

  • Status changed from New to Accepted
  • Is Regression set to Yes

Wow. Good finding. Thanks.

The faulty commit was https://review.typo3.org/49976

I commented there.

#3

Updated by Markus Klein over 4 years ago

A question though:

Are you sure about the

&
thing? Because this is not URL-encoded, but HTML-encoded.
http_build_query is documented to return URL-encoded strings.

#4

Updated by Markus Klein over 4 years ago

  • Status changed from Accepted to Needs Feedback
  • Priority changed from Must have to -- undefined --
  • Target version deleted (Candidate for patchlevel)
  • Is Regression deleted (Yes)

@David: I double-checked the code now and it seems rather correct. Please explain where your & chars come from.

#5

Updated by Carsten Falkenberg over 4 years ago

I experienced the same issue, after submitting a form. removed all third-party extensions, except my distribution.

PHP 7.0.19
TYPO3 8.7.1

#6

Updated by Helmut Hummel over 4 years ago

Could it be that you both have arg-separator.output set to & in your php.ini?

#7

Updated by Carsten Falkenberg over 4 years ago

that is correct. arg_separator.output is set to & on that server.
changing the value to & solved the problem.

#8

Updated by Gerrit Code Review over 4 years ago

  • Status changed from Needs Feedback to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52922

#9

Updated by Gerrit Code Review over 4 years ago

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52923

#10

Updated by Markus Klein over 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#11

Updated by Markus Klein over 4 years ago

  • Related to Task #81366: Make sure all http_build_query() calls use a defined separator added
#12

Updated by Markus Klein over 4 years ago

  • Has duplicate Bug #81565: ID parameter needs to be passed for the cHash calculation! added
#13

Updated by Benni Mack over 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF