[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:TYPO3com <noreply@typo3.com> Tested-by:
Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by:
Simon Gilli <typo3@gilbertsoft.org> Tested-by:
Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by:
Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by:
Simon Gilli <typo3@gilbertsoft.org> Reviewed-by:
Christian Kuhn <lolli@schwarzbu.ch>
Showing
- typo3/sysext/backend/Classes/Http/Application.php 9 additions, 0 deletionstypo3/sysext/backend/Classes/Http/Application.php
- typo3/sysext/core/Classes/Http/ApplicationType.php 88 additions, 0 deletionstypo3/sysext/core/Classes/Http/ApplicationType.php
- typo3/sysext/core/Tests/Unit/Http/ApplicationTypeTest.php 81 additions, 0 deletionstypo3/sysext/core/Tests/Unit/Http/ApplicationTypeTest.php
- typo3/sysext/frontend/Classes/Http/Application.php 5 additions, 0 deletionstypo3/sysext/frontend/Classes/Http/Application.php
- typo3/sysext/install/Classes/Http/Application.php 2 additions, 0 deletionstypo3/sysext/install/Classes/Http/Application.php
Please register or sign in to comment