95878[TASK] Use PSR-14 event for page URI cache hash calculation
Commit message
Review
-
Code review CR +2 Done
- Benni Mack +2
- Oli Bartsch +1
- Wouter Wolters +1
-
Verified V +2 Done
- Benni Mack +2
- Oli Bartsch +1
- Wouter Wolters +1
- core-ci +1 CI
Issues 1
Files 4
- typo3/sysext/core/Classes/Routing/Event/AfterPageUriGeneratedEvent.php+13 −0
- typo3/sysext/core/Classes/Routing/PageRouter.php4+8 −32
- typo3/sysext/frontend/Classes/EventListener/CalculatePageUriCacheHashEventListener.php6new+59 −0
- typo3/sysext/frontend/Tests/Unit/EventListener/CalculatePageUriCacheHashEventListenerTest.phpnew+101 −0
Review log 2029
Show 24 earlier messages
-
Benni Mack uploaded patch set 1 09/16/26, 14:02
-
Benni Mack uploaded patch set 2 09/16/26, 14:07
-
core-ci voted on patch set 1 V +1 09/16/26, 14:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108692
-
core-ci voted on patch set 2 V -1 09/16/26, 14:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108694
-
Benni Mack uploaded patch set 3
V -109/16/26, 14:25 -
Benni Mack uploaded patch set 4 09/16/26, 14:30
-
Benni Mack marked it ready for review 09/16/26, 14:30
-
Benni Mack updated the commit message in patch set 5 09/16/26, 14:33
-
core-ci voted on patch set 3 V -1 09/16/26, 14:33 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108697
-
core-ci voted on patch set 4 V -1 09/16/26, 14:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108698
-
core-ci voted on patch set 5 V -1 09/16/26, 14:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108699
-
Benni Mack uploaded patch set 6
V -109/16/26, 16:03 -
core-ci voted on patch set 6 V +1 09/16/26, 16:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108702
-
Benni Mack marked it ready for review 09/16/26, 16:35
-
Wouter Wolters voted on patch set 6 CR +1 09/16/26, 16:45
-
Wouter Wolters voted on patch set 6 V +1 09/16/26, 16:54
-
Jochen Roth voted on patch set 6 CR +1 V +1 09/17/26, 21:24
-
Oli Bartsch voted on patch set 6 V -1 09/17/26, 21:50
-
Oli Bartsch commented on patch set 6 09/17/26, 22:10
Worth adding CacheHashCalculator is now a shared container service instead of a per-PageRouter makeInstance(), so GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] is frozen at container build time. That matches PageArgumentValidator, which already injects it, so generation and validation now share one instance. An improvement, but a behaviour change that could be mentioned.PageRouter.php:320This is an unrelated behaviour change, and it regresses generated URLs. generateUri(1000, ['key' => 'value', 'cHash' => 'staleincoming']) before: https://oli.it/?key=value&cHash=00f30ec5… after: https://oli.it/?cHash=00f30ec5…&key=value The hash value is correct in both cases, but the URL string differs. Stripping it here, before the enhancers and route generation run, is also strictly safer than letting it pollute $originalParameters, which is handed to enhanceForGeneration()/decorateForGeneration(), to RouteSorter, and to $event->getParameters(). I suggest to keep the unset and the listener only ever has to,append.PageRouter.php:386With the null check above, $matchedRoute is now always true. Either drop it or keep the previous `$matchedRoute && $pageRouteResult &&` form.CalculatePageUriCacheHashEventListener.php:25This advice produces links with an invalid cHash, so please remove or rewrite it. The hash is computed from $event->getPageArguments()->getDynamicArguments(), not from the URI query. A listener that runs before this one and adds a query argument is therefore never covered by the hash. Running after this listener fails in exactly the same way, for the same reason. So today there is no way at all for a listener to add a cacheable query argument to a generated page URI. Either drop the paragraph, or hash the URI's query instead of the PageArguments. The second option changes the hash for enhanced routes though, so it needs its own careful look.CalculatePageUriCacheHashEventListener.php:52The parse_str() / http_build_query() round-trip is lossy. parse_str() rewrites "." and " " in top-level keys to "_" and collapses duplicate keys. Inside PageRouter's own flow this is same as today. There is already a parse_str(), so no regression from this patch, but you now put a second round-trip on whatever URI a preceding listener produced, and silently mangle it. So I think this is avoidable. Build the query from $event->getPageArguments()->getQueryArguments() plus the cHash, exactly as PageRouter did before, instead of re-parsing the URI. Combined with keeping the unset() in PageRouter, the listener then only appends and never rewrites.CalculatePageUriCacheHashEventListener.php:60setUri() is called unconditionally, so every URI with dynamic arguments goes through the round-trip above even when nothing changes. Worth an early return when the computed query equals the existing one. -
Benni Mack uploaded patch set 7
CR +1V +109/22/26, 15:16 -
Benni Mack commented on patch set 7 09/22/26, 15:17
Reply
DonePageRouter.php:320ReplyDonePageRouter.php:386ReplyDoneCalculatePageUriCacheHashEventListener.php:25ReplyDoneCalculatePageUriCacheHashEventListener.php:52ReplyDoneCalculatePageUriCacheHashEventListener.php:60ReplyDone -
core-ci voted on patch set 7 V -1 09/22/26, 15:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108998
-
core-ci voted on patch set 7 V +1 09/22/26, 17:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108998
-
Oli Bartsch updated the commit message in patch set 8
V +109/23/26, 08:39 -
Oli Bartsch voted on patch set 8 CR +1 V +1 09/23/26, 08:39
-
core-ci voted on patch set 8 V +1 09/23/26, 08:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109036
-
Wouter Wolters voted on patch set 8 CR +1 V +1 09/23/26, 12:33
-
Benni Mack voted on patch set 8 CR +2 V +2 09/23/26, 12:35
-
Benni Mack merged patch set 9 09/23/26, 12:35