Commit d15b46b9 authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[!!!][TASK] Remove constants TYPO3_MODE and TYPO3_REQUESTTYPE

Resolves: #96196
Related: #92947
Releases: main
Change-Id: I9f8e9949c5443eb0324b8406346f98e87bfacc20
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72456

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 529661be
......@@ -189,14 +189,10 @@ class Bootstrap
*
* Script execution will be aborted if something fails here.
*
* @throws \RuntimeException when TYPO3_REQUESTTYPE was not set before, setRequestType() needs to be called before
* @internal This is not a public API method, do not use in own extensions
*/
public static function baseSetup()
{
if (!defined('TYPO3_REQUESTTYPE')) {
throw new \RuntimeException('No Request Type was set, TYPO3 does not know in which context it is run.', 1450561838);
}
if (!Environment::isComposerMode() && ClassLoadingInformation::isClassLoadingInformationAvailable()) {
ClassLoadingInformation::registerClassLoadingInformation();
}
......
......@@ -35,9 +35,7 @@ use TYPO3\CMS\Core\Utility\PathUtility;
* This class only defines what is configured through the environment, does not do any checks if paths exist
* etc. This should be part of the application or the SystemEnvironmentBuilder.
*
* In your application, use it like this:
*
* Instead of writing "TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI" call "Environment::isCli()"
* In your application, use it like this: "Environment::isCli()"
*/
class Environment
{
......
......@@ -61,9 +61,6 @@ class SystemEnvironmentBuilder
public static function run(int $entryPointLevel = 0, int $requestType = self::REQUESTTYPE_FE)
{
self::defineBaseConstants();
self::defineTypo3RequestTypes();
self::setRequestType($requestType | ($requestType === self::REQUESTTYPE_BE && (str_contains($_SERVER['REQUEST_URI'] ?? '', '/typo3/ajax/') || strpos($_REQUEST['route'] ?? '', '/ajax/') === 0) ? TYPO3_REQUESTTYPE_AJAX : 0));
self::defineLegacyConstants($requestType === self::REQUESTTYPE_FE ? 'FE' : 'BE');
$scriptPath = self::calculateScriptPath($entryPointLevel, $requestType);
$rootPath = self::calculateRootPath($entryPointLevel, $requestType);
......@@ -342,65 +339,6 @@ class SystemEnvironmentBuilder
return defined('TYPO3_COMPOSER_MODE') && TYPO3_COMPOSER_MODE;
}
/**
* Define TYPO3_REQUESTTYPE* constants that can be used for developers to see if any context has been hit
* also see setRequestType(). Is done at the very beginning so these parameters are always available.
*
* @deprecated since v11, method can be removed in v12
*/
protected static function defineTypo3RequestTypes()
{
// Check one of the constants and return early if already defined,
// needed if multiple requests are handled in one process, for instance in functional testing.
if (defined('TYPO3_REQUESTTYPE_FE')) {
return;
}
/** @deprecated since v11, will be removed in v12. */
define('TYPO3_REQUESTTYPE_FE', self::REQUESTTYPE_FE);
/** @deprecated since v11, will be removed in v12. */
define('TYPO3_REQUESTTYPE_BE', self::REQUESTTYPE_BE);
/** @deprecated since v11, will be removed in v12. */
define('TYPO3_REQUESTTYPE_CLI', self::REQUESTTYPE_CLI);
/** @deprecated since v11, will be removed in v12. */
define('TYPO3_REQUESTTYPE_AJAX', self::REQUESTTYPE_AJAX);
/** @deprecated since v11, will be removed in v12. */
define('TYPO3_REQUESTTYPE_INSTALL', self::REQUESTTYPE_INSTALL);
}
/**
* Defines the TYPO3_REQUESTTYPE constant so the environment knows which context the request is running.
*
* @param int $requestType
* @deprecated since v11, method can be removed in v12
*/
protected static function setRequestType(int $requestType)
{
// Return early if already defined,
// needed if multiple requests are handled in one process, for instance in functional testing.
if (defined('TYPO3_REQUESTTYPE')) {
return;
}
/** @deprecated since v11, will be removed in v12. Use Core\Http\ApplicationType API or $request->getAttribute('applicationType') instead */
define('TYPO3_REQUESTTYPE', $requestType);
}
/**
* Define constants and variables
*
* @param string $mode
* @deprecated since v11, method can be removed in v12
*/
protected static function defineLegacyConstants(string $mode)
{
// Return early if already defined,
// needed if multiple requests are handled in one process, for instance in functional testing.
if (defined('TYPO3_MODE')) {
return;
}
/** @deprecated since v11, will be removed in v12. Use Core\Http\ApplicationType API instead */
define('TYPO3_MODE', $mode);
}
/**
* Checks if request type is cli.
* Falls back to check PHP_SAPI in case request type is not provided
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\FormProtection;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
......@@ -109,7 +110,7 @@ class FormProtectionFactory
$isAjaxCall = false;
$request = $GLOBALS['TYPO3_REQUEST'] ?? null;
if ($request instanceof ServerRequestInterface
&& (bool)((int)$request->getAttribute('applicationType') & TYPO3_REQUESTTYPE_AJAX)
&& (bool)((int)$request->getAttribute('applicationType') & SystemEnvironmentBuilder::REQUESTTYPE_AJAX)
) {
$isAjaxCall = true;
}
......@@ -142,7 +143,7 @@ class FormProtectionFactory
$isInstallTool = false;
$request = $GLOBALS['TYPO3_REQUEST'] ?? null;
if ($request instanceof ServerRequestInterface
&& (bool)((int)$request->getAttribute('applicationType') & TYPO3_REQUESTTYPE_INSTALL)
&& (bool)((int)$request->getAttribute('applicationType') & SystemEnvironmentBuilder::REQUESTTYPE_INSTALL)
) {
$isInstallTool = true;
}
......
......@@ -242,36 +242,43 @@ return [
'TYPO3_MODE' => [
'restFiles' => [
'Deprecation-92947-DeprecateTYPO3_MODEAndTYPO3_REQUESTTYPEConstants.rst',
'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
],
],
'TYPO3_REQUESTTYPE' => [
'restFiles' => [
'Deprecation-92947-DeprecateTYPO3_MODEAndTYPO3_REQUESTTYPEConstants.rst',
'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
],
],
'TYPO3_REQUESTTYPE_FE' => [
'restFiles' => [
'Deprecation-92947-DeprecateTYPO3_MODEAndTYPO3_REQUESTTYPEConstants.rst',
'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
],
],
'TYPO3_REQUESTTYPE_BE' => [
'restFiles' => [
'Deprecation-92947-DeprecateTYPO3_MODEAndTYPO3_REQUESTTYPEConstants.rst',
'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
],
],
'TYPO3_REQUESTTYPE_CLI' => [
'restFiles' => [
'Deprecation-92947-DeprecateTYPO3_MODEAndTYPO3_REQUESTTYPEConstants.rst',
'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
],
],
'TYPO3_REQUESTTYPE_AJAX' => [
'restFiles' => [
'Deprecation-92947-DeprecateTYPO3_MODEAndTYPO3_REQUESTTYPEConstants.rst',
'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
],
],
'TYPO3_REQUESTTYPE_INSTALL' => [
'restFiles' => [
'Deprecation-92947-DeprecateTYPO3_MODEAndTYPO3_REQUESTTYPEConstants.rst',
'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
],
],
];
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment