Review main Merged Breaking

91156[!!!][TASK] Have stateless TypoScriptFrontendController

Christian Kuhn CR +2 V +2 Expert +599 −646 updated 10/24/25, 23:53

Commit message

This change was very painful to come up with. It is important
to streamline the overall FE rendering chain and to especially
make 'cached page with not cached elements' scenarios more
straight forward.

The patch finally turns TypoScripFrontendController into a
stateless service class. It can be ultimately dissolved with
further patches relatively easily now: All properties are gone,
remaining consumers are adapted and state is taken care in a
more straight forward way. The change enables development of
ContentObjectRenderer since its manual constructor dependency
to TSFE is finally gone.

The main brain melting offender in this patch is the distinction
between rendering a page first-time and having non cached content
elements (or not), and getting a page from cache that may have
non cached elements to still be calculated. The main problem is
that we don't have a structure returned by elements for content
they want to have added to the HTTP response or the body content
parts, but the entire FE rendering relies on state being gathered
in the PageRenderer, AssetCollector and TypoScriptFrontendController
singletons. While we will have to resolve this situation at some
point, this change focuses on TypoScriptFrontendController alone,
while facilitating the existing mechanics around PageRenderer
and friends.

To understand the detail decisions of this patch, a general
understanding of FE page rendering with and without "not cached"
elements is required. Not cached elements in FE rendering are
typically "USER_INT", "COA_INT" and "uncached extbase".
When a page containing such elements is first rendered (no
cache_pages DB entry), all content elements are rendered one
by one. Elements that can be cached return their body part string
(for instance the TEXT or FLUIDTEMPLATE string result). This content
is concatenated to what has been returned by previous elements already.
Elements may also register additional things, for instance JS or CSS
resources. They do this by adding state to PageRenderer and
AssetCollector. When the rendering triggers a "not cached" element,
those elements return a placeholder instead of their content. Its
rendering is delayed and they do not add state to PageRenderer and
friends at this point. Instead, a registry entry for this non cached
element is added that contains state from this point in time.
This includes the specific ContentObjectRenderer, the TS rendering
definition of this element, and the name of the placeholder
marker, plus some less important details.

After this, all content elements that can be cached created their
content and registered additional state in PageRenderer. This
state is written to "cache_pages": The content string with cached
elements string result and uncached placeholders, plus the state
created in PageRenderer and AssetCollector, plus the registry of
uncached elements with their rendering definition, plus a series of
more organizational data like cache lifetimes. The system essentially
writes a snapshot of the rendering state after cacheable contents
have been processed and rendering definitions for the "delayed"
uncached elements. The page generation then continues - with *then*
rendering the delayed uncached elements: They substitute their
content placeholders with their actual content string and they
add additional state to PageRenderer. There are funny details,
for instance the uncached elements processing is recursive since
some uncached elements (USER_INT) may register uncached elements
again that need to be reprocessed. Or the state of the
RegisterStack which might differ to the actual processing
defined via TypoScript.

After that, the final content string and the state from
PageRenderer and friends is put together to create Response.

On next call, when a cache_pages DB row is found, the system
state is reset to the point above by setting PageRenderer,
AssetCollector and other state. The cached element rendering
step is skipped, the uncached elements are rendered according
to their previously cached rendering definitions. Then everything
is put together and returned again.

TypoScriptFrontendController played an important role in this
code flow by gathering the state in various opaque properties
and by containing the main rendering logic.

The patch dissolves this state from the class, and we will look
at each property one-by-one:

- $cacheGenerated
  This property was useless after a previous refactoring and
  removed straight away together with a small simplification
  in CacheLifetimeCalculator.

- $pageContentWasLoadedFromCache
  This carries an information if a "cache_pages" cache entry was found
  and state has been created from cache. It decides if rendering
  of cached elements is required and if a cache_pages row should
  be written afterwards. This information is now parked in
  PageParts (Request attribute 'frontend.page.parts').

- $newHash
  This is the cache_pages row identifier. It is calculated when
  TypoScript is available and before the cache_pages row is fetched.
  It is needed to later write a cache_pages row, so we need to park
  it somewhere (at least for now). It can be useful for extensions
  that need to fiddle on this low level as well. That information
  is now added to CacheDataCollector (Request attribute
  'frontend.cache.collector').

- $absRefPrefix
  This is still used in a couple of places. Its value depends on
  TypoScript and NormalizedParams which are both Request attributes.
  This property is now substituted by a simple service called
  FrontendUrlPrefix that takes the Request and returns the final
  value.

- $debugInformationHeader
  This is a HTTP header added when debugging is enabled containg
  dates when the page cache has been generated and when it expires.
  These information tuples are now cached in cache_pages directly,
  the header is generated after rendering from them, the property
  is no longer needed.

- $additionalHeaderData,
  $additionalFooterData,
  $config['INTincScript_ext']['additionalHeaderData'],
  $config['INTincScript_ext']['additionalFooterData']
  There was quite some forth and back logic dealing with content
  elements that registered data here. To make a long story short,
  the entire state can be avoided by writing it to PageRenderer
  directly and being handled just like any other PageRenderer
  state in the cache row. A single core consumer in EX:seo is
  adapted accordingly.

- $config['pageTitleCache']
  There is quite some frontend fuzz around creating the pages HTML
  head <title> tag. Similar to other state it needs to be created
  by both uncached and cached elements. Its state is for now
  parked in PageParts and handled similar to other data that needs
  to be preserved in caches but can be manipulated by not cached
  elements as well.

- $config['INTincScript_ext']['divKey']
  This is a hash used to substituted PageRenderer placeholders with
  their final content when uncached elements are involved. It is
  now written to cache_pages as name "pageRendererSubstitutionHash"
  and parked in PageParts.

- $config['INTincScript']
  This is the registry of not cached elements with their rendering
  definitions, state and content substitution hashes. It is now
  modeled as PageParts "notCachedContentElementRegistry". The data
  array structure is kept with the exception that "substKey" (the
  search-replace key in the content string) is now a dedicated
  array key and not the array index anymore.

There is room for detail improvements and for bigger structural
changes. For instance the involved middlewares could benefit from
cleanups now, and the general "uncached elements" handling, as well
as the PageRenderer could see improvements.

The patch removes last properties from TypoScriptFrontendController,
so we add some final ReST files to document relevant information for
extension developers again, even though we wrote about most of it in
v13 already.

Review

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

Issues 4

Files 59

Show 39 more files

Review log 5394

Show 3569 earlier messages
  1. Christian Kuhn uploaded patch set 1 10/18/25, 14:23

  2. core-ci voted on patch set 1 V +1 10/18/25, 14:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86985

  3. Christian Kuhn uploaded patch set 2 V +1 10/18/25, 16:09

  4. core-ci voted on patch set 2 V +1 10/18/25, 16:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86989

  5. Christian Kuhn uploaded patch set 3 V +1 10/19/25, 10:50

  6. core-ci voted on patch set 3 V +1 10/19/25, 10:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87010

  7. Christian Kuhn uploaded patch set 4 V +1 10/19/25, 11:08

  8. Christian Kuhn uploaded patch set 5 10/19/25, 11:10

  9. core-ci voted on patch set 4 V +1 10/19/25, 11:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87011

  10. core-ci voted on patch set 5 V +1 10/19/25, 11:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87012

  11. Christian Kuhn uploaded patch set 6 V +1 10/20/25, 10:35

  12. core-ci voted on patch set 6 V +1 10/20/25, 10:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87069

  13. Christian Kuhn uploaded patch set 7 V +1 10/20/25, 14:33

  14. core-ci voted on patch set 7 V +1 10/20/25, 14:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87088

  15. Christian Kuhn uploaded patch set 8 V +1 10/20/25, 15:29

  16. core-ci voted on patch set 8 V +1 10/20/25, 15:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87094

  17. Christian Kuhn uploaded patch set 9 V +1 10/20/25, 16:22

  18. core-ci voted on patch set 9 V -1 10/20/25, 16:39 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87099

  19. Christian Kuhn uploaded patch set 10 V -1 10/20/25, 16:50

  20. core-ci voted on patch set 10 V +1 10/20/25, 16:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87102

  21. Christian Kuhn uploaded patch set 11 V +1 10/22/25, 09:57

  22. core-ci voted on patch set 11 V +1 10/22/25, 10:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87230

  23. Christian Kuhn uploaded patch set 12 V +1 10/22/25, 20:52

  24. core-ci voted on patch set 12 V +1 10/22/25, 21:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87306

  25. Christian Kuhn uploaded patch set 13 V +1 10/22/25, 21:17

  26. core-ci voted on patch set 13 V +1 10/22/25, 21:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87308

  27. Christian Kuhn uploaded patch set 14 V +1 10/22/25, 21:31

  28. core-ci voted on patch set 14 V +1 10/22/25, 21:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87309

  29. Christian Kuhn uploaded patch set 15 V +1 10/22/25, 21:45

  30. core-ci voted on patch set 15 V +1 10/22/25, 21:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87310

  31. Christian Kuhn uploaded patch set 16 V +1 10/22/25, 22:19

  32. Christian Kuhn uploaded patch set 17 10/22/25, 22:23

  33. core-ci voted on patch set 16 V +1 10/22/25, 22:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87311

  34. core-ci voted on patch set 17 V +1 10/22/25, 22:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87312

  35. Christian Kuhn uploaded patch set 18 V +1 10/22/25, 22:55

  36. core-ci voted on patch set 18 V +1 10/22/25, 23:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87345

  37. core-ci voted on patch set 17 V +1 10/22/25, 23:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87346

  38. Christian Kuhn uploaded patch set 19 V +1 10/22/25, 23:09

  39. Christian Kuhn uploaded patch set 20 10/22/25, 23:13

  40. core-ci voted on patch set 19 V +1 10/22/25, 23:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87347

  41. core-ci voted on patch set 20 V +1 10/22/25, 23:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87348

  42. Christian Kuhn uploaded patch set 21 V +1 10/23/25, 00:43

  43. Christian Kuhn uploaded patch set 22 10/23/25, 00:47

  44. core-ci voted on patch set 21 V +1 10/23/25, 00:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87350

  45. core-ci voted on patch set 22 V +1 10/23/25, 00:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87351

  46. Christian Kuhn uploaded patch set 23 V +1 10/23/25, 00:57

  47. core-ci voted on patch set 23 V +1 10/23/25, 01:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87352

  48. Christian Kuhn uploaded patch set 24 V +1 10/23/25, 01:17

  49. Christian Kuhn uploaded patch set 25 10/23/25, 01:18

  50. core-ci voted on patch set 25 V +1 10/23/25, 01:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87355

  51. core-ci voted on patch set 24 V +1 10/23/25, 01:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87354

  52. Christian Kuhn updated the commit message in patch set 26 V +1 10/23/25, 01:39

  53. Christian Kuhn updated the commit message in patch set 27 10/23/25, 01:42

  54. Christian Kuhn updated the commit message in patch set 28 10/23/25, 01:43

  55. Christian Kuhn updated the commit message in patch set 29 10/23/25, 01:45

  56. Christian Kuhn updated the commit message in patch set 30 10/23/25, 01:47

  57. Christian Kuhn updated the commit message in patch set 31 10/23/25, 01:50

  58. core-ci voted on patch set 26 V +1 10/23/25, 01:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87356

  59. core-ci voted on patch set 27 V +1 10/23/25, 01:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87357

  60. core-ci voted on patch set 28 V +1 10/23/25, 01:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87358

  61. core-ci voted on patch set 29 V +1 10/23/25, 01:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87359

  62. core-ci voted on patch set 30 V +1 10/23/25, 01:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87360

  63. core-ci voted on patch set 31 V +1 10/23/25, 02:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87361

  64. Christian Kuhn updated the commit message in patch set 32 V +1 10/23/25, 02:04

  65. core-ci voted on patch set 32 V +1 10/23/25, 02:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87363

  66. Benni Mack commented on patch set 32 10/23/25, 06:43

    PageRenderer.php:195

    I love all of this!
  67. Christian Kuhn commented on patch set 32 10/24/25, 10:14

    PageRenderer.php:195 Reply

    i think we'll go with a dedicated and rather simple change to not cache the content twice in cache_pages when this change is done. a bigger overhaul of PR will need more time, though and includes some design decisions.
  68. Christian Kuhn uploaded patch set 33 V +1 10/24/25, 10:27

  69. core-ci voted on patch set 33 V +1 10/24/25, 10:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87484

  1. Christian Kuhn uploaded patch set 34 V +1 10/24/25, 11:50

  2. Christian Kuhn updated the commit message in patch set 35 10/24/25, 11:51

  3. core-ci voted on patch set 34 V +1 10/24/25, 11:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87488

  4. core-ci voted on patch set 35 V +1 10/24/25, 12:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87489

  5. Christian Kuhn uploaded patch set 36 V +1 10/24/25, 13:21

  6. core-ci voted on patch set 36 V +1 10/24/25, 13:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87500

  7. Christian Kuhn uploaded patch set 37 V +1 10/24/25, 14:14

  8. core-ci voted on patch set 37 V +1 10/24/25, 14:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87508

  9. Christian Kuhn uploaded patch set 38 V +1 10/24/25, 14:26

  10. core-ci voted on patch set 38 V +1 10/24/25, 14:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87509

  11. Benni Mack commented on patch set 38 10/24/25, 15:01

    PageContentErrorHandler.php:121

    we could clean this up directly now

    AbstractContentObject.php:79

    this will become a problem for a lot of third-party extensions (such as solr), we need to document this.

    AfterCacheableContentIsGeneratedEvent.php:24

    good comment to keep in an RST file

    AfterCachedPageIsPersistedEvent.php:46

    we could use extension scanner here (so Rector can deal with it)

    ShouldUseCachedPageDataIfAvailableEvent.php:37

    We could use Extension Scanner here.

    FrontendUrlPrefix.php:19

    a quick comment that this service is here to evaluate absRefPrefix would be great.

    FrontendUrlPrefix.php:20

    internal or not? If not internal, we should add this to the RST for extension authors to know.
  12. Benni Mack updated the commit message in patch set 39 V +1 10/24/25, 15:08

  13. core-ci voted on patch set 39 V +1 10/24/25, 15:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87519

  14. Benni Mack uploaded patch set 40 V +1 10/24/25, 15:34

  15. Benni Mack commented on patch set 39 CR +1 V +1 10/24/25, 15:34

    PageContentErrorHandler.php:121 Reply

    Done

    AbstractContentObject.php:79 Reply

    Done

    AfterCacheableContentIsGeneratedEvent.php:24 Reply

    Done

    AfterCachedPageIsPersistedEvent.php:46 Reply

    Done

    ShouldUseCachedPageDataIfAvailableEvent.php:37 Reply

    Done

    FrontendUrlPrefix.php:19 Reply

    Done

    FrontendUrlPrefix.php:20 Reply

    Done
  16. Benni Mack voted on patch set 40 CR +1 V +1 10/24/25, 15:35

  17. core-ci voted on patch set 40 V +1 10/24/25, 15:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87520

  18. Stefan Bürk voted on patch set 40 CR +1 V +1 10/24/25, 16:06

  19. Christian Kuhn commented on patch set 40 CR +2 V +2 10/24/25, 16:15

    thank you!
  20. Christian Kuhn merged patch set 41 10/24/25, 16:15

  21. Garvin Hicking commented on patch set 41 10/24/25, 16:28

    Breaking-107831-AfterCachedPageIsPersistedEventNoLongerReceivesTypoScriptFrontendController.rst:36

    ```suggestion can now be found in the :php:`Request` which is available using :php:`$event->getRequest()`. ```

    Breaking-107831-RemovedTypoScriptFrontendController.rst:24

    ```suggestion AbstractContentObject->getTypoScriptFrontendController() ```

    Breaking-107831-RemovedTypoScriptFrontendController.rst:26

    ```suggestion All API methods that returned an instance of :php:`TypoScriptFrontendController`, ```
  22. Garvin Hicking commented on patch set 41 10/24/25, 16:28

    Huge success. Noted some typos while reading, will do in a combined docs patch in the future.
  23. Christian Kuhn commented on patch set 41 10/24/25, 16:30

    Breaking-107831-AfterCachedPageIsPersistedEventNoLongerReceivesTypoScriptFrontendController.rst:36 Reply

    thx. i can take core of these typos in a next patch as drive-by if that is ok with you.
  24. Christian Kuhn commented on patch set 41 10/24/25, 23:46

    Breaking-107831-AfterCachedPageIsPersistedEventNoLongerReceivesTypoScriptFrontendController.rst:36 Reply

    Done

    Breaking-107831-RemovedTypoScriptFrontendController.rst:24 Reply

    Done

    Breaking-107831-RemovedTypoScriptFrontendController.rst:26 Reply

    Done
  25. Christian Kuhn commented on patch set 41 10/24/25, 23:53

    Breaking-107831-RemovedTypoScriptFrontendController.rst:24 Reply