Breaking: #102621 - Most TSFE members marked internal or read-only
See forge#102621
Description
Most properties and methods of class
Typo have
been marked
@internal or "read-only".
Typo ("TSFE") is a god object within the TYPO3 frontend
rendering chain: It is used by multiple middlewares that call TSFE methods to create
state in it, it is used within
Content and various other
classes to update and retrieve state. It is also registered as
$GLOBALS
at some point and thus available as global state object.
This makes the class the biggest anti-pattern we have within the frontend - class
Content is problematic as well, but that is a different story.
The current role of
Typo leads to very complex and
opaque state handling within the frontend rendering, is the true source of many
hard to fix issues and prevents Core development from implementing cool new features.
The TYPO3 Core strives to resolve large parts of this with TYPO3 v13: State needed by lower level code is being modeled as request attributes or handled locally in middlewares, methods are moved out of the class into middlewares to improve encapsulation and code flow.
To do that within continued TYPO3 v13 development, the Core needs to mark various
methods and properties
@internal, and needs to mark more strict access patterns
on others.
The solution is to look at public properties of
Typo,
and to declare those as
@internal, which extensions typically should not need to
deal with at all. Others (like for instance
id) are actively used by extensions and
will be substituted by something different later, and are thus marked as "allowed to read,
but never write" for extensions. This allows implementation of a deprecation layer for those
"read-only" properties later, while those marked
@internal can vanish without
further notice. A similar strategy is added for methods, leaving only a few not
marked
@internal, which the Core will deprecate with a compatibility layer later.
The following public class properties have been marked "read-only", and have later been
deprecated with the full deprecation of
Typo in
TYPO3 v13.4, see Deprecation: #105230 - TypoScriptFrontendController and $GLOBALS['TSFE'].
Typo- UseScript Frontend Controller->id $request->getinsteadAttribute ('frontend. page. information')->get Id () Typo- UseScript Frontend Controller->root Line $request->getinsteadAttribute ('frontend. page. information')->get Root Line () Typo- UseScript Frontend Controller->page $request->getinsteadAttribute ('frontend. page. information')->get Page Record () Typo- Avoid usages altogether, available asScript Frontend Controller->content Pid @internalcall using$request->getAttribute ('frontend. page. information')->get Content From Pid () Typo- Avoid altogether, create own instance usingScript Frontend Controller->sys_ page GeneralUtility:: make Instance (Page Repository:: class) Typo- UseScript Frontend Controller->config $request->getinstead ofAttribute ('frontend. typoscript')->get Config Array () config['config'] Typo- Create an ownScript Frontend Controller->c Obj Contentinstance, callObject Renderer setandRequest ($request) start($request->get Attribute ('frontend. page. information')->get Page Record (), 'pages') Typo- UseScript Frontend Controller->config ['root Line'] $request->getinsteadAttribute ('frontend. page. information')->get Local Root Line ()
The following public class properties have been marked
@internal - in general
all properties not listed above. They contain information usually not relevant within
extensions. The TYPO3 core will model them differently.
TypoScript Frontend Controller->abs Ref Prefix Typo- Use request attributeScript Frontend Controller->no_ cache frontend.insteadcache. instruction TypoScript Frontend Controller->additional Header Data TypoScript Frontend Controller->additional Footer Data TypoScript Frontend Controller->register TypoScript Frontend Controller->register Stack TypoScript Frontend Controller->record Register TypoScript Frontend Controller->current Record TypoScript Frontend Controller->content TypoScript Frontend Controller->last Img Resource Info
The following methods have been marked
@internal and may vanish anytime:
Typo- extensions should not create own instances of TSFEScript Frontend Controller->__ construct () TypoScript Frontend Controller->determine Id () TypoScript Frontend Controller->get Page Access Failure Reasons () TypoScript Frontend Controller->calculate Link Vars () TypoScript Frontend Controller->is Generate Page () TypoScript Frontend Controller->prepare Page Content Generation () TypoScript Frontend Controller->generate Page_ post Processing () TypoScript Frontend Controller->generate Page Title () TypoScript Frontend Controller->INTinc Script () TypoScript Frontend Controller->INTinc Script_ load JSCode () TypoScript Frontend Controller->is INTinc Script () TypoScript Frontend Controller->apply Http Headers To Response () TypoScript Frontend Controller->is Static Cacheble () TypoScript Frontend Controller->new CObj () TypoScript Frontend Controller->log Deprecated Typoscript () TypoScript Frontend Controller->unique Hash () TypoScript Frontend Controller->set_ cache_ timeout_ default () Typo- UseScript Frontend Controller->set_ no_ cache () $request->getinsteadAttribute ('frontend. cache. instruction')->disable Cache () Typo- UseScript Frontend Controller->s L () General` insteadUtility:: make Instance (Language Service Factory:: class)->create From Site Language ($request->get Attribute ('language'))->s L () TypoScript Frontend Controller->get_ cache_ timeout () Typo- UseScript Frontend Controller->get Requested Id () $request->getinsteadAttribute ('routing')->get Page Id () Typo- UseScript Frontend Controller->get Language () $request->getinsteadAttribute ('language') ?? $request->get Attribute ('site')->get Default Language () Typo- UseScript Frontend Controller->get Site () $request->getinsteadAttribute ('site') Typo- Use dependency injection orScript Frontend Controller->get Context () GeneralinsteadUtility:: make Instance () Typo- UseScript Frontend Controller->get Page Arguments () $request->getinsteadAttribute ('routing')
Impact
Writing to the listed read-only properties may break the frontend rendering,
using the properties or methods marked as
@internal may raise fatal PHP errors.
Affected installations
The majority of extensions should already use the above properties that are marked read-only
for reading only: Updating their state can easily lead to unexpected behavior. Most
extensions also don't consume the properties or methods marked as
@internal.
Extension developers should watch out for usages of
Typo in
general and reduce usages as much as possible.
Migration
The migration strategy depends on the specific use case. The frontend rendering chain continues to add state that is needed by extensions as PSR-7 request attributes. Debugging the incoming request within an extension often reveals a proper alternative.