Review main Merged

95742[BUGFIX] Skip stdWrap cache write if caching is disabled

Georg Ringer CR +2 V +2 Normal +114 −0 updated 10/02/26, 16:29

Commit message

The stdWrap function "cache" wrote its content to the "hash" cache
even when caching was disabled for the current request, for instance
during a backend user preview of hidden pages and records. Regular
visitors were served that poisoned cache entry afterwards.

Writing is now guarded by the same isCachingAllowed() check that
already protects reading and the "cache" property of content objects.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Wouter Wolters +1
    • Ayke Halder +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Benni Mack +2
    • Ayke Halder +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 3

Review log 1113

  1. Georg Ringer uploaded patch set 1 09/09/26, 06:21

  2. Georg Ringer commented on patch set 1 09/09/26, 06:21

    This change is ready for review.
  3. core-ci voted on patch set 1 V +1 09/09/26, 06:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108143

  4. Markus Klein voted on patch set 1 CR +1 09/09/26, 14:00

  5. Ayke Halder commented on patch set 1 CR +1 09/09/26, 14:03

    Everything works perfectly now. Unfortunately I cannot reproduce my poisened cache case without this patch applied in TYPO3 main anymore… still trying.

    ContentObjectRendererStdWrapCacheTest.php:70

    ```suggestion } #[Test] public function cacheReadGetsExistingCachedContentAndDoesNotChangeCacheIfCachingIsAllowed(): void { $subject = $this->get(ContentObjectRenderer::class); $subject->setRequest($this->createRequest(new CacheInstruction())); $this->get(CacheManager::class)->getCache('hash')->set('myCacheKey', ['content' => 'cachedContent', 'cacheTags' => []]); self::assertSame('cachedContent', $subject->stdWrap('voidContent', ['cache.' => ['key' => 'myCacheKey']])); self::assertSame('cachedContent', $this->get(CacheManager::class)->getCache('hash')->get('myCacheKey')['content']); } #[Test] public function cacheReadDoesNotGetExistingCachedContentAndDoesNotChangeCacheIfCachingIsDisabled(): void { $cacheInstruction = new CacheInstruction(); $cacheInstruction->disableCache('Test: Disabled cache due to enabled frontend.preview aspect isPreview.'); $subject = $this->get(ContentObjectRenderer::class); $subject->setRequest($this->createRequest($cacheInstruction)); $this->get(CacheManager::class)->getCache('hash')->set('myCacheKey', ['content' => 'cachedContent', 'cacheTags' => []]); self::assertSame('previewContent', $subject->stdWrap('previewContent', ['cache.' => ['key' => 'myCacheKey']])); self::assertSame('cachedContent', $this->get(CacheManager::class)->getCache('hash')->get('myCacheKey')['content']); } ``` May we add these two additional tests to check the cache reading side?
  6. Georg Ringer uploaded patch set 2 CR +1 V +1 09/09/26, 14:20

  7. core-ci voted on patch set 2 V +1 09/09/26, 14:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108192

  8. Ayke Halder commented on patch set 2 CR +1 V +1 09/09/26, 15:04

    Works perfectly with this patch applied! And I could reproduce the issue in current main without this patch - see https://forge.typo3.org/issues/110602#issue_description_wiki

    ContentObjectRendererStdWrapCacheTest.php:70 Reply

    Done
  9. Wouter Wolters voted on patch set 2 CR +1 09/09/26, 15:22

  10. Simon Schaufelberger voted on patch set 2 CR +1 V +1 09/09/26, 22:43

  11. Ayke Halder commented on patch set 2 09/11/26, 15:11

    Does this also need a backport to v13 as priority bugfix?
  12. Benni Mack commented on patch set 2 CR +2 V +2 10/02/26, 16:29

    no 13.4
  13. Benni Mack merged patch set 3 10/02/26, 16:29