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->get
insteadAttribute ('frontend. page. information')->get Id () Typo
- UseScript Frontend Controller->root Line $request->get
insteadAttribute ('frontend. page. information')->get Root Line () Typo
- UseScript Frontend Controller->page $request->get
insteadAttribute ('frontend. page. information')->get Page Record () Typo
- Avoid usages altogether, available asScript Frontend Controller->content Pid @internal
call using$request->get
Attribute ('frontend. page. information')->get Content From Pid () Typo
- Avoid altogether, create own instance usingScript Frontend Controller->sys_ page General
Utility:: make Instance (Page Repository:: class) Typo
- UseScript Frontend Controller->config $request->get
instead ofAttribute ('frontend. typoscript')->get Config Array () config
['config'] Typo
- Create an ownScript Frontend Controller->c Obj Content
instance, callObject Renderer set
andRequest ($request) start
($request->get Attribute ('frontend. page. information')->get Page Record (), 'pages') Typo
- UseScript Frontend Controller->config ['root Line'] $request->get
insteadAttribute ('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.
Typo
Script Frontend Controller->abs Ref Prefix Typo
- Use request attributeScript Frontend Controller->no_ cache frontend.
insteadcache. instruction Typo
Script Frontend Controller->additional Header Data Typo
Script Frontend Controller->additional Footer Data Typo
Script Frontend Controller->register Typo
Script Frontend Controller->register Stack Typo
Script Frontend Controller->record Register Typo
Script Frontend Controller->current Record Typo
Script Frontend Controller->content Typo
Script 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 () Typo
Script Frontend Controller->determine Id () Typo
Script Frontend Controller->get Page Access Failure Reasons () Typo
Script Frontend Controller->calculate Link Vars () Typo
Script Frontend Controller->is Generate Page () Typo
Script Frontend Controller->prepare Page Content Generation () Typo
Script Frontend Controller->generate Page_ post Processing () Typo
Script Frontend Controller->generate Page Title () Typo
Script Frontend Controller->INTinc Script () Typo
Script Frontend Controller->INTinc Script_ load JSCode () Typo
Script Frontend Controller->is INTinc Script () Typo
Script Frontend Controller->apply Http Headers To Response () Typo
Script Frontend Controller->is Static Cacheble () Typo
Script Frontend Controller->new CObj () Typo
Script Frontend Controller->log Deprecated Typoscript () Typo
Script Frontend Controller->unique Hash () Typo
Script Frontend Controller->set_ cache_ timeout_ default () Typo
- UseScript Frontend Controller->set_ no_ cache () $request->get
insteadAttribute ('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 () Typo
Script Frontend Controller->get_ cache_ timeout () Typo
- UseScript Frontend Controller->get Requested Id () $request->get
insteadAttribute ('routing')->get Page Id () Typo
- UseScript Frontend Controller->get Language () $request->get
insteadAttribute ('site')->get Default Language () Typo
- UseScript Frontend Controller->get Site () $request->get
insteadAttribute ('site') Typo
- Use dependency injection orScript Frontend Controller->get Context () General
insteadUtility:: make Instance () Typo
- UseScript Frontend Controller->get Page Arguments () $request->get
insteadAttribute ('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.