Skip to content

Commit fdd3800

Browse files
committed
[!!!][TASK] Avoid $_GET / $_POST safety net
Resolves: TYPO3-Documentation/Changelog-To-Doc#1453 Releases: main
1 parent cf47ec1 commit fdd3800

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Documentation/ApiOverview/RequestLifeCycle/Middlewares.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ TYPO3 has implemented the PSR-15 approach in the following way:
6666

6767
#. This response is passed back to the execution flow.
6868

69+
.. versionchanged:: 14.0
70+
71+
Middlewares must not rely on the PHP superglobals `$_GET` / `$_POST`
72+
(and legacy `$HTTP_GET_VARS` / :php:`$HTTP_POST_VARS`) being synchronized
73+
with the PSR-7 request. TYPO3 no longer resets these globals from request data.
74+
75+
Also note that :php:`$GLOBALS['TYPO3_REQUEST']` is a compatibility layer and
76+
may not be available in all middleware positions (it is set later in the
77+
application flow). Always use the PSR-7 request
78+
(:php:`\Psr\Http\Message\ServerRequestInterface`) passed into
79+
`process()` and pass it explicitly to services that need it.
80+
6981
.. index:: Request handling; Middleware
7082
.. _request-handling-middlewares:
7183

Documentation/ApiOverview/RequestLifeCycle/Typo3Request.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ If a request is needed initialize one as described in
171171
Last resort: global variable
172172
----------------------------
173173

174+
.. versionchanged:: 14.0
175+
176+
The global request variable is a compatibility layer and is no longer
177+
guaranteed to be available in all execution contexts. In particular,
178+
it may not be set yet in early PSR-15 middlewares.
179+
180+
Always prefer the PSR-7 request object passed explicitly to the current
181+
execution context.
182+
183+
174184
TYPO3 provides the request object also in the global variable
175185
:php:`$GLOBALS['TYPO3_REQUEST']`. Whenever it is possible the request should be
176186
retrieved within the contexts described above. But this is not always possible

0 commit comments

Comments
 (0)