Skip to content
Snippets Groups Projects
Commit a085e885 authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[!!!][FEATURE] Avoid TSFE->config['config']

Frontend TypoScript has two special details, next to
'configuration' ("constants") and 'setup'.

First, there is the determined "PAGE" object that depends
on type / typeNum. It allows to render multiple different
variants of a pages content. Historically, this has often
been a "print" view, nowadays, this is usually a "json"
variant, or some XML for sitemaps.

A frontend is not rendered without a proper PAGE object.
The FE rendering chain determines the given 'type' and maps
it to a configured PAGE with this 'typeNum', defaulting
to zero '0'.
The patch models the determined PAGE object to the Request
attribute 'FrontendTypoScript' now, which is used by FE
RequestHandler to manage rendering of this PAGE type.

Second special thing is 'config' TypoScript as top-level
'config' settings. Those can be overridden by the specific
PAGE object (often 'page.config'). A typical use case is
'json.config.disableAllHeaderCode = 1'.
This "merged" 'config' array has been available as
TSFE->config['config'] before. The patch makes the merged
config available in the 'FrontendTypoScript' object as
well, available in the Request object as
'frontend.typoscript' attribute.

The patch adapts all usages of TSFE->config['config'] to
the attribute.

There is a special quirk with 'config': This part of
TypoScript 'setup' is so important, that it needs to be
available in 'fully cached page' scenarios as well, to
for instance decide if a content-length header should be
added to the response.
This has been the reason 'config' has been cached along
with page cache content in 'page' cache before.
The patch changes this and adds dedicated cache entries
for 'merged config' in the (file based) 'typoscript' cache.
This reduces page cache size a bit and allows re-using
these 'config' cache accross different pages when they
are identical, which is determined by the cache identifiers.

All these changes are logical follow-ups to the TypoScript
parser that has been implemented with v12.
They pave the way to extract TypoScript calculation from
TypoScriptFrontendController with upcoming patches.

Next to this refactoring, the existing hooks in this area
had to fall, especially to get rid of their dependency to
"pObj" TypoScriptFrontendController. They are mostly
substituted by new events, details are documented with the
.rst files and class comments.

The patch reduces usages of $GLOBALS['TSFE'] and usages
of TypoScriptFrontendController in general.

$GLOBALS['TSFE']->config['config'] is still available as
b/w compat layer (a dedicated deprecation will follow),
but core usages have been removed. This became a bit
complicated with TimeTrackerInitialization and
WorkspacePreview middlewares: Both are run before the
final TypoScript 'config' is determined, so they do
not have that attribute attached to their incoming
Request. But they still need to know TS 'config'
details to decide on details *after* calling lower handle()
middlewares. They by now accessed $GLOBALS['TSFE'], which
is (still) set by a lower middleware. To avoid this
indirect state usage, these middlewares now register an event
listener that is dispatched after TypoScript 'config' has been
determined, and set local state to know if they should add
additional Response data.

Resolves: #102932
Releases: main
Change-Id: I8282f7a93fe9594e78865db63a3e656cc4d5f8da
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82522


Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarcore-ci <typo3@b13.com>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 9501c458
No related branches found
No related tags found
No related merge requests found
Showing
with 563 additions and 118 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment