From c0350b1e75027d2e54fff2489a10e8e17f17474b Mon Sep 17 00:00:00 2001 From: Oliver Bartsch <bo@cedev.de> Date: Mon, 29 Nov 2021 16:14:07 +0100 Subject: [PATCH] [!!!][TASK] Remove HTTP headers manipulating methods in HttpUtility In order to properly handle PSR-7 response objects, methods, which directly manipulate HTTP headers, should be avoided. Therefore following methods from HttpUtility are now removed: - `redirect()` - `setResponseCode()` - `setResponseCodeAndExit()` Resolves: #96143 Related: #94316 Releases: main Change-Id: Id353bb427118d148aa251b144eb866a4bd9ff822 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72378 Tested-by: core-ci <typo3@b13.com> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Benni Mack <benni@typo3.org> --- .../core/Classes/Utility/HttpUtility.php | 47 ------------------- ...g-96107-DeprecatedFunctionalityRemoved.rst | 3 ++ .../Php/MethodCallStaticMatcher.php | 3 ++ 3 files changed, 6 insertions(+), 47 deletions(-) diff --git a/typo3/sysext/core/Classes/Utility/HttpUtility.php b/typo3/sysext/core/Classes/Utility/HttpUtility.php index c730444ff1bd..d7994168000d 100644 --- a/typo3/sysext/core/Classes/Utility/HttpUtility.php +++ b/typo3/sysext/core/Classes/Utility/HttpUtility.php @@ -92,53 +92,6 @@ class HttpUtility const SCHEME_HTTP = 1; const SCHEME_HTTPS = 2; - /** - * Sends a redirect header response and exits. Additionally the URL is - * checked and if needed corrected to match the format required for a - * Location redirect header. By default the HTTP status code sent is - * a 'HTTP/1.1 303 See Other'. - * - * @param string $url The target URL to redirect to - * @param string $httpStatus An optional HTTP status header. Default is 'HTTP/1.1 303 See Other' - * @deprecated since v11, will be removed in v12. - */ - public static function redirect($url, $httpStatus = self::HTTP_STATUS_303) - { - // Deprecation logged by setResponseCode() - self::setResponseCode($httpStatus); - header('Location: ' . GeneralUtility::locationHeaderUrl($url)); - die; - } - - /** - * Set a specific response code like 404. - * - * @param string $httpStatus One of the HTTP_STATUS_* class class constants, default to self::HTTP_STATUS_303 - * @deprecated since v11, will be removed in v12. - */ - public static function setResponseCode($httpStatus = self::HTTP_STATUS_303) - { - trigger_error( - 'All methods in ' . __CLASS__ . ', manipulationg HTTP headers, are deprecated and will be removed in v12.', - E_USER_DEPRECATED - ); - - header($httpStatus); - } - - /** - * Set a specific response code and exit script execution. - * - * @param string $httpStatus One of the HTTP_STATUS_* class class constants, default to self::HTTP_STATUS_303 - * @deprecated since v11, will be removed in v12. - */ - public static function setResponseCodeAndExit($httpStatus = self::HTTP_STATUS_303) - { - // Deprecation logged by setResponseCode() - self::setResponseCode($httpStatus); - die; - } - /** * Builds a URL string from an array with the URL parts, as e.g. output by parse_url(). * diff --git a/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst index 93eaa01b1ba3..1f65efdc5fb8 100644 --- a/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst +++ b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst @@ -49,6 +49,9 @@ The following PHP static class methods that have previously been marked as depre - :php:`\TYPO3\CMS\Backend\Utility\BackendUtility::explodeSoftRefParserList()` - :php:`\TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick` - :php:`\TYPO3\CMS\Core\Utility\GeneralUtility::stdAuthCode()` +- :php:`\TYPO3\CMS\Core\Utility\HttpUtility::redirect()` +- :php:`\TYPO3\CMS\Core\Utility\HttpUtility::setResponseCode()` +- :php:`\TYPO3\CMS\Core\Utility\HttpUtility::setResponseCodeAndExit()` The following methods changed signature according to previous deprecations in v11 at the end of the argument list: diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php index 738bd623e8c8..2b8847e0ef3e 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php @@ -1108,6 +1108,7 @@ return [ 'maximumNumberOfArguments' => 2, 'restFiles' => [ 'Deprecation-94316-DeprecatedHTTPHeaderManipulatingMethodsFromHttpUtility.rst', + 'Breaking-96107-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Core\Utility\HttpUtility::setResponseCode' => [ @@ -1115,6 +1116,7 @@ return [ 'maximumNumberOfArguments' => 1, 'restFiles' => [ 'Deprecation-94316-DeprecatedHTTPHeaderManipulatingMethodsFromHttpUtility.rst', + 'Breaking-96107-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Core\Utility\HttpUtility::setResponseCodeAndExit' => [ @@ -1122,6 +1124,7 @@ return [ 'maximumNumberOfArguments' => 1, 'restFiles' => [ 'Deprecation-94316-DeprecatedHTTPHeaderManipulatingMethodsFromHttpUtility.rst', + 'Breaking-96107-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Core\Localization\LanguageService::create' => [ -- GitLab