Bug #81293

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

Added by David Bascom about 2 years ago. Updated 11 months ago.

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

100%

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, '', '&')
)

Bildschirmfoto 2017-05-22 um 11.46.39.png View (195 KB) David Bascom, 2017-05-22 12:01

exception.jpg View (170 KB) Carsten Falkenberg, 2017-05-23 16:42


Related issues

Related to TYPO3 Core - Bug #78002: Require cHash for cached plugin actions in Extbase Closed 2016-09-20
Related to TYPO3 Core - Task #81366: Make sure all http_build_query() calls use a defined separator Closed 2017-05-29
Duplicated by TYPO3 Core - Bug #81565: ID parameter needs to be passed for the cHash calculation! Closed 2017-06-13

Associated revisions

Revision 82aa4141 (diff)
Added by Markus Klein about 2 years ago

[BUGFIX] Make encoding of parameters for cHash independent of PHP settings

http_build_query() internally uses the PHP setting arg-separator.output
to identify the URL parameter separator.
Our code relies on having a simple ampersand as this character.
If the PHP is set to a different configuration the code will fail.

This is fixed by enforcing the ampersand. Moreover we force RFC3986
encoding to ensure that decoding with rawurldecode() does the right
thing.

Releases: master, 8.7
Resolves: #81293
Change-Id: I321c7bba03ee597adc29a2f8429b8fc9ac3b709d
Reviewed-on: https://review.typo3.org/52922
Reviewed-by: Christian Kuhn <>
Tested-by: TYPO3com <>
Reviewed-by: Carsten Falkenberg <>
Tested-by: Carsten Falkenberg <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

Revision 7c8f5be9 (diff)
Added by Markus Klein about 2 years ago

[BUGFIX] Make encoding of parameters for cHash independent of PHP settings

http_build_query() internally uses the PHP setting arg-separator.output
to identify the URL parameter separator.
Our code relies on having a simple ampersand as this character.
If the PHP is set to a different configuration the code will fail.

This is fixed by enforcing the ampersand. Moreover we force RFC3986
encoding to ensure that decoding with rawurldecode() does the right
thing.

Change-Id: I92f9b877201c634303a2e387d9aad49106151f63
Releases: master, 8.7
Resolves: #81293
Reviewed-on: https://review.typo3.org/52923
Tested-by: TYPO3com <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

History

#1 Updated by Markus Klein about 2 years ago

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

#2 Updated by Markus Klein about 2 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 about 2 years ago

A question though:

Are you sure about the

&amp;
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 about 2 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 about 2 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 about 2 years ago

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

#7 Updated by Carsten Falkenberg about 2 years ago

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

#8 Updated by Gerrit Code Review about 2 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 about 2 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 about 2 years ago

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

#11 Updated by Markus Klein about 2 years ago

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

#12 Updated by Markus Klein about 2 years ago

  • Duplicated by Bug #81565: ID parameter needs to be passed for the cHash calculation! added

#13 Updated by Benni Mack 11 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF