diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-94228-DeprecateExtbaseRequestGetRequestUri.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-94228-DeprecateExtbaseRequestGetRequestUri.rst new file mode 100644 index 0000000000000000000000000000000000000000..1b60cef255accc0d3284cb2c3b18784133a6c159 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-94228-DeprecateExtbaseRequestGetRequestUri.rst @@ -0,0 +1,52 @@ +.. include:: ../../Includes.txt + +=============================================================== +Deprecation: #94228 - Deprecate extbase request getRequestUri() +=============================================================== + +See :issue:`94228` + +Description +=========== + +To further prepare extbase towards PSR-7 compatible requests, the +extbase :php:`TYPO3\CMS\Extbase\Mvc\Request` has to be streamlined. + +Method :php:`getRequestUri()` has been deprecated and shouldn't be +used any longer. + + +Impact +====== + +Using the method will log a deprecation message, it will be +removed with v12. + + + +Affected Installations +====================== + +Extbase based extensions may use this method. The extension scanner +will find usages as weak match. + + +Migration +========= + +When :php:`getRequestUri()` is called in extensions, the same information +can be retrieved from the native PSR-7 request. At the moment, this is usually +only available using :php:`$GLOBALS['TYPO3_REQUEST']`, but this will change +when the extbase request is compatible with PSR-7 ServerRequestInterface. +A substitution looks like this for now: + +.. code-block:: php + + // @todo Adapt this example as soon as extbase Request implements ServerRequestInterface + $request = $GLOBALS['TYPO3_REQUEST']; + /** @var NormalizedParams $normalizedParams */ + $normalizedParams = $request->getAttribute('normalizedParams'); + $requestUrl = $normalizedParams->getRequestUrl(); + + +.. index:: PHP-API, FullyScanned, ext:extbase diff --git a/typo3/sysext/extbase/Classes/Mvc/Request.php b/typo3/sysext/extbase/Classes/Mvc/Request.php index 37e6f5a90ef296fda88ffe9826d3b3e289583337..e185395e1e0e755b99a2bf581565bf4efe358837 100644 --- a/typo3/sysext/extbase/Classes/Mvc/Request.php +++ b/typo3/sysext/extbase/Classes/Mvc/Request.php @@ -103,11 +103,6 @@ class Request implements RequestInterface */ protected $originalRequestMappingResults; - /** - * @var string - */ - protected $requestUri; - /** * @var bool TRUE if the current request is cached, false otherwise. */ @@ -519,25 +514,21 @@ class Request implements RequestInterface return $request->getMethod(); } - /** - * Sets the request URI - * - * @param string $requestUri URI of this web request - * @internal only to be used within Extbase, not part of TYPO3 Core API. - */ - public function setRequestUri($requestUri) - { - $this->requestUri = $requestUri; - } - /** * Returns the request URI * * @return string URI of this web request + * @deprecated since v11, will be removed in v12 */ public function getRequestUri() { - return $this->requestUri; + trigger_error('Method ' . __METHOD__ . ' is deprecated and will be removed in TYPO3 12.0', E_USER_DEPRECATED); + + // @todo Global access is obsolete as soon as this class implements ServerRequestInterface + $mainRequest = $GLOBALS['TYPO3_REQUEST']; + /** @var NormalizedParams $normalizedParams */ + $normalizedParams = $mainRequest->getAttribute('normalizedParams'); + return $normalizedParams->getRequestUrl(); } /** diff --git a/typo3/sysext/extbase/Classes/Mvc/Web/RequestBuilder.php b/typo3/sysext/extbase/Classes/Mvc/Web/RequestBuilder.php index 14a74e1ae3ba400eb1fc980e67bb22a7f2faf82b..a45316c4dafc9bdc971d7484b3a968c35ba611cc 100644 --- a/typo3/sysext/extbase/Classes/Mvc/Web/RequestBuilder.php +++ b/typo3/sysext/extbase/Classes/Mvc/Web/RequestBuilder.php @@ -17,7 +17,6 @@ namespace TYPO3\CMS\Extbase\Mvc\Web; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Error\Http\PageNotFoundException; -use TYPO3\CMS\Core\Http\NormalizedParams; use TYPO3\CMS\Core\Routing\PageArguments; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\ArrayUtility; @@ -161,8 +160,6 @@ class RequestBuilder implements SingletonInterface { $this->loadDefaultValues(); $pluginNamespace = $this->extensionService->getPluginNamespace($this->extensionName, $this->pluginName); - /** @var NormalizedParams $normalizedParams */ - $normalizedParams = $mainRequest->getAttribute('normalizedParams'); $queryArguments = $mainRequest->getAttribute('routing'); if ($queryArguments instanceof PageArguments) { $parameters = $queryArguments->get($pluginNamespace) ?? []; @@ -190,7 +187,6 @@ class RequestBuilder implements SingletonInterface $request->setControllerAliasToClassNameMapping($this->controllerAliasToClassMapping); $request->setControllerName($this->controllerClassToAliasMapping[$controllerClassName]); $request->setControllerActionName($actionName); - $request->setRequestUri($normalizedParams->getRequestUrl()); if (isset($parameters['format']) && is_string($parameters['format']) && $parameters['format'] !== '') { $request->setFormat(filter_var($parameters['format'], FILTER_SANITIZE_STRING)); } else { diff --git a/typo3/sysext/fluid/Classes/View/StandaloneView.php b/typo3/sysext/fluid/Classes/View/StandaloneView.php index 2e3074e059ecddc6fdce20e93ea7d0ad8a1c23a4..8e0bba68e1e5cef06117b9eb5ae0e8e64c7f6efe 100644 --- a/typo3/sysext/fluid/Classes/View/StandaloneView.php +++ b/typo3/sysext/fluid/Classes/View/StandaloneView.php @@ -49,7 +49,6 @@ class StandaloneView extends AbstractTemplateView $configurationManager->setContentObject($contentObject); $request = $objectManager->get(Request::class); - $request->setRequestUri(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); $renderingContext = $objectManager->get(RenderingContext::class, $this); $renderingContext->setRequest($request); parent::__construct($renderingContext); diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php index 615fb1606c21a5b1c69d7b888f5c52ca0f238621..615dbd9f47c34a48272abacc48115cc0d0550780 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php @@ -4823,4 +4823,11 @@ return [ 'Deprecation-94223-ExtbaseRequest-getBaseUri.rst' ], ], + 'TYPO3\CMS\Extbase\Mvc\Request->getRequestUri' => [ + 'numberOfMandatoryArguments' => 0, + 'maximumNumberOfArguments' => 0, + 'restFiles' => [ + 'Deprecation-94228-DeprecateExtbaseRequestGetRequestUri.rst' + ], + ], ];