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

[TASK] Add application type to request

The cardinal issue with constant 'TYPO3_MODE' is that it's
value is NOT constant: It is defined early during bootstrap and
derived from information that is hand over from entry point
index.php's. Depending on this, value is either 'FE' or 'BE'.

Using that constant or the related constant 'TYPO3_REQUESTTYPE'
makes it impossible to change scope from backend to frontend
in one PHP call. This actively blocks executing sub requests,
use cases are for instance executing a frontend request within
a running backend call (eg. view module), or executing frontend
requests from cli (eg. some indexer).

Dropping 'TYPO3_MODE' and its friends is thus a requirement to
finally allow such scenarios. We can't get rid of the distinction
between 'frontend' and 'backend' altogether since some legit use
cases like different paths or security settings depend on it.

Looking at TYPO3 bootstrap, the only class that 'knows' if it's
frontend or backend are the Application classes of ext:frontend
and ext:backend. They are the PSR-15 entry points, they create a
first PSR-7 request object if it has not been given, and then
call the PSR-15 middleware stack dispatcher to create a PSR-7
response, starting with this first request object.

The solution to get rid of 'TYPO3_MODE' is to add the information
'I am a frontend or backend request' as attribute to the request
object in the Application classes. To simplify things, the helper
class ApplicationType is introduced that answers isFrontend() and
isBackend() for a given request object.

Documentation changelog files with full details on the impact of
this change will be added with an upcoming patch that deprecates
the constants in master.

This patch targets master and v10: 'TYPO3_MODE' is used in
extensions quite often. Having the API in both v10 and v11 helps
extension developers to deliver deprecation free extensions that
are compatible with both v10 and v11 in one version. Codewise,
neither the 'applicationType' attribute nor the helper class
harm in v10.

Resolves: #92951
Related: #92947
Releases: master, 10.4
Change-Id: Ia4ea637b252b774cf72492402e6be52ee4695242
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/66942


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarSimon Gilli <typo3@gilbertsoft.org>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: default avatarSimon Gilli <typo3@gilbertsoft.org>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 36a2051f
Branches
Tags
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment