Deprecation: #99615 - GeneralUtility::_GPmerged()¶
See forge#99615
Description¶
Method \TYPO3\CMS\Backend\Utility\GeneralUtility::_GPmerged()
has
been marked as deprecated and should not be used any longer.
Modern code should access GET and POST data from the PSR-7 ServerRequestInterface
,
and should avoid accessing superglobals $_GET
and $_POST
directly. This helps creating controller classes with a clean architecture. Some
GeneralUtility
related helper methods like _GPmerged()
violate this,
using them is considered a technical debt. They are being phased out.
Impact¶
Calling the method will raise a deprecation level log error and will stop working with TYPO3 v13.
Affected installations¶
Instances with extensions using GeneralUtility::_GPmerged()
are affected.
The extension scanner will find usages with a strong match.
Migration¶
GeneralUtility::_GPmerged()
is a helper method that retrieves
request parameters and returns the value, while POST parameters take
precedence over GET parameters, if both exist.
The same result can be achieved by retrieving arguments from the request object.
An instance of the PSR-7 ServerRequestInterface
is hand over to
controllers by TYPO3 core PSR-15 RequestHandlerInterface
and Middleware
implementations, and is available in various related scopes like the Frontend
ContentObjectRenderer
.
Typical code:
// Before
$getMergedWithPost = GeneralUtility::_GPmerged('tx_scheduler');
// After
$getMergedWithPost = $request->getQueryString()['tx_scheduler'];
ArrayUtility::mergeRecursiveWithOverrule($getMergedWithPost, $request->getParsedBody()['tx_scheduler']);