Review main Merged

91996[BUGFIX] Avoid caching content twice in cache_pages

Christian Kuhn CR +2 V +2 Normal +67 −112 updated 12/03/25, 16:04

Commit message

With TypoScriptFrontendController being gone we can start
looking at deeper constructs that surface their issues now.

The PageRenderer is particularly delicate. It becomes more
and more obvious this construct needs an overhaul. We will
try to isolate it to open up development.

As a starter, we'll fix a rather nasty issue: In frontend,
when non-cached elements ("INT") are involved, the generated
content containing cached elements and placeholders for the
non-cached elements is cached twice in cache_pages: Once as
'content' array key, and a second time as PageRenderer state
via $bodyContent property. With "fully cached" render() is
called that triggers reset() at the end to clear state. With
non-cached elements involved, renderPageWithUncachedObjects()
does not reset state, so $bodyContent is later part of the
cached PageRenderer state. There are various options to
approach this with one hindrance being the render-postProcess
hook, which receives $bodyContent and should continue to
receive it to not break existing consumers.

The solution is to for now reset $bodyContent in
renderPageWithUncachedObjects() to have the empty string
cached instead, and then reset this property just before
the hook is called. This solution catches both "empty cache"
and "got cached page, calculate non-cached elements now"
scenarios. The patch also inlines two protected methods to
make the main methods a bit more obvious.

The patch is not an answer to the overall situation around
"full" and "partial" content caching. The responsibilities
who takes care of it are not sorted out and there is a happy
mixture of this state being set and hand over. We'll have to
work on that with future patches.

Note, while "the main content is cached twice" sounds really
bad, it isn't in practice: cache_pages is usually gzip'ed,
which suppresses long duplicate strings effectively. This is
why we don't work on a v13 backport of this bugfix: Its ugly,
but the impact is limited and it would be much harder to fix
in v13 with the many refactorings that happened around TSFE
in v14.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Anja Leichsenring +1
    • Stefan Bürk +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Anja Leichsenring +1
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 710

  1. Christian Kuhn uploaded patch set 1 12/03/25, 13:40

  2. core-ci voted on patch set 1 V -1 12/03/25, 13:48 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/91537

  3. Christian Kuhn uploaded patch set 2 V -1 12/03/25, 14:18

  4. core-ci voted on patch set 2 V +1 12/03/25, 14:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/91538

  5. Christian Kuhn updated the commit message in patch set 3 V +1 12/03/25, 15:06

  6. Anja Leichsenring voted on patch set 3 CR +1 V +1 12/03/25, 15:15

  7. core-ci voted on patch set 3 V +1 12/03/25, 15:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/91540

  8. Stefan Bürk voted on patch set 3 CR +1 V +1 12/03/25, 15:46

  9. Christian Kuhn voted on patch set 3 CR +2 V +2 12/03/25, 16:03

  10. Christian Kuhn merged patch set 4 12/03/25, 16:04