diff --git a/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php b/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php index a73c7b95f1e074a29d1bed9cbd0f4bb5a739de5a..e62bd4b55176163e04248da410cddfa1286b81bc 100644 --- a/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php +++ b/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php @@ -295,7 +295,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface */ protected function getApplicationContext() { - $applicationContext = GeneralUtility::getApplicationContext(); + $applicationContext = Environment::getContext(); $this->systemInformation[] = [ 'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:toolbarItems.sysinfo.applicationcontext', 'value' => (string)$applicationContext, diff --git a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php index c4eab9748184d574254c5e5f9b97e91cbb83df4b..48910292cd20b36e425b2cd7ecd0a4a669a18299 100644 --- a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php +++ b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Authentication; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Cache\CacheManager; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder; @@ -464,7 +465,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication if ((int)$GLOBALS['BE_USER']->user['ses_backuserid'] !== 0) { return false; } - if (GeneralUtility::getApplicationContext()->isDevelopment() && $this->isAdmin()) { + if (Environment::getContext()->isDevelopment() && $this->isAdmin()) { return true; } $systemMaintainers = $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemMaintainers'] ?? []; diff --git a/typo3/sysext/core/Classes/Console/CommandApplication.php b/typo3/sysext/core/Classes/Console/CommandApplication.php index 598a9cc52efdbbf9137b08ce38b99e522acd61cd..5032962ae0439d83085e2daf71e91ae03a6e08b2 100644 --- a/typo3/sysext/core/Classes/Console/CommandApplication.php +++ b/typo3/sysext/core/Classes/Console/CommandApplication.php @@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Context\VisibilityAspect; use TYPO3\CMS\Core\Context\WorkspaceAspect; use TYPO3\CMS\Core\Core\ApplicationInterface; use TYPO3\CMS\Core\Core\Bootstrap; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -52,7 +53,7 @@ class CommandApplication implements ApplicationInterface $this->application = new Application('TYPO3 CMS', sprintf( '%s (Application Context: <comment>%s</comment>)', TYPO3_version, - GeneralUtility::getApplicationContext() + Environment::getContext() )); $this->application->setAutoExit(false); } diff --git a/typo3/sysext/core/Classes/Console/CommandRequestHandler.php b/typo3/sysext/core/Classes/Console/CommandRequestHandler.php index f7df6131a77a4cdefd4826950e2ab5b637b28b3a..c68a4cb856faad204d4b5315b8374332fde945d7 100644 --- a/typo3/sysext/core/Classes/Console/CommandRequestHandler.php +++ b/typo3/sysext/core/Classes/Console/CommandRequestHandler.php @@ -22,6 +22,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\ConsoleOutput; use TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication; use TYPO3\CMS\Core\Core\Bootstrap; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -46,7 +47,7 @@ class CommandRequestHandler implements RequestHandlerInterface $this->application = new Application('TYPO3 CMS', sprintf( '%s (Application Context: <comment>%s</comment>)', TYPO3_version, - GeneralUtility::getApplicationContext() + Environment::getContext() )); } diff --git a/typo3/sysext/core/Classes/Core/ClassLoadingInformation.php b/typo3/sysext/core/Classes/Core/ClassLoadingInformation.php index b6bcb1ae8e9fec1b61f9f03a1305bd4d4ae99ba8..a0686c4472125e68e721947bbf7d9f934d8a34c1 100644 --- a/typo3/sysext/core/Classes/Core/ClassLoadingInformation.php +++ b/typo3/sysext/core/Classes/Core/ClassLoadingInformation.php @@ -214,7 +214,7 @@ class ClassLoadingInformation */ protected static function isTestingContext() { - return GeneralUtility::getApplicationContext()->isTesting(); + return Environment::getContext()->isTesting(); } /** diff --git a/typo3/sysext/core/Classes/ExpressionLanguage/SiteConditionProvider.php b/typo3/sysext/core/Classes/ExpressionLanguage/SiteConditionProvider.php index 2c5eb89fe6f2cb77245501f5a53a523c9e33e93a..937c9379edc78987b8424d88763559c99ccd7ead 100644 --- a/typo3/sysext/core/Classes/ExpressionLanguage/SiteConditionProvider.php +++ b/typo3/sysext/core/Classes/ExpressionLanguage/SiteConditionProvider.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Core\ExpressionLanguage; * The TYPO3 project - inspiring people to share! */ -use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Core\Environment; class SiteConditionProvider extends AbstractProvider { @@ -27,7 +27,7 @@ class SiteConditionProvider extends AbstractProvider $typo3->branch = TYPO3_branch; $typo3->devIpMask = trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']); $this->expressionLanguageVariables = [ - 'applicationContext' => (string)GeneralUtility::getApplicationContext(), + 'applicationContext' => (string)Environment::getContext(), 'typo3' => $typo3, ]; } diff --git a/typo3/sysext/core/Classes/ExpressionLanguage/TypoScriptConditionProvider.php b/typo3/sysext/core/Classes/ExpressionLanguage/TypoScriptConditionProvider.php index c38d32ca8d9149c5d9c1eac95e94a1f28f2ddfc1..56211f1c62798d85b6a9ea213e844f0b6411cd67 100644 --- a/typo3/sysext/core/Classes/ExpressionLanguage/TypoScriptConditionProvider.php +++ b/typo3/sysext/core/Classes/ExpressionLanguage/TypoScriptConditionProvider.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\ExpressionLanguage; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\ExpressionLanguage\FunctionsProvider\Typo3ConditionFunctionsProvider; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -34,7 +35,7 @@ class TypoScriptConditionProvider extends AbstractProvider $typo3->devIpMask = trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']); $this->expressionLanguageVariables = [ 'request' => GeneralUtility::makeInstance(RequestWrapper::class, $GLOBALS['TYPO3_REQUEST'] ?? null), - 'applicationContext' => (string)GeneralUtility::getApplicationContext(), + 'applicationContext' => (string)Environment::getContext(), 'typo3' => $typo3, ]; $this->expressionLanguageProviders = [ diff --git a/typo3/sysext/core/Classes/Page/PageRenderer.php b/typo3/sysext/core/Classes/Page/PageRenderer.php index 363f4f7ab2bc30439e44e826f52374943b2e5c46..e0619c9b18d00da3448a0c0762e58a3c09f451ab 100644 --- a/typo3/sysext/core/Classes/Page/PageRenderer.php +++ b/typo3/sysext/core/Classes/Page/PageRenderer.php @@ -1291,7 +1291,7 @@ class PageRenderer implements SingletonInterface } $packages = GeneralUtility::makeInstance(PackageManager::class)->getActivePackages(); - $isDevelopment = GeneralUtility::getApplicationContext()->isDevelopment(); + $isDevelopment = Environment::getContext()->isDevelopment(); $cacheIdentifier = 'requireJS_' . md5(implode(',', array_keys($packages)) . ($isDevelopment ? ':dev' : '') . GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT')); /** @var FrontendInterface $cache */ $cache = static::$cache ?? GeneralUtility::makeInstance(CacheManager::class)->getCache('assets'); diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index e45bd9f5fa076d156910b90436284e8ed4d70053..ba65299e91f3e63513a46be2992d37a3bca46447 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -20,7 +20,6 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Core\ApplicationContext; -use TYPO3\CMS\Core\Core\Bootstrap; use TYPO3\CMS\Core\Core\ClassLoadingInformation; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Http\RequestFactory; @@ -84,6 +83,7 @@ class GeneralUtility * The application context * * @var \TYPO3\CMS\Core\Core\ApplicationContext + * @deprecated will be removed in TYPO3 v11. */ protected static $applicationContext; @@ -3783,7 +3783,7 @@ class GeneralUtility * * @param \TYPO3\CMS\Core\Core\ApplicationContext $applicationContext * @throws \RuntimeException if applicationContext is overridden - * @internal This is not a public API method, do not use in own extensions + * @internal This is not a public API method, do not use in own extensions, will probably be removed in TYPO3 v11. */ public static function presetApplicationContext(ApplicationContext $applicationContext) { @@ -3800,7 +3800,7 @@ class GeneralUtility * variable in between multiple tests before it is re-initialized using presetApplicationContext() * which otherwise throws an exception if the internal variable is already set. * - * @internal May be changed or removed any time + * @internal May be changed or removed any time, will probably be removed in TYPO3 v11. */ public static function resetApplicationContext(): void { @@ -3811,9 +3811,11 @@ class GeneralUtility * Get the ApplicationContext * * @return \TYPO3\CMS\Core\Core\ApplicationContext + * @deprecated since TYPO3 v10.2, will be removed in TYPO3 v11, use Environment::getContext() instead. */ public static function getApplicationContext() { + trigger_error('GeneralUtility::getApplicationContext() has been superseded by Environment API. This method will be removed in TYPO3 v11. Use Environment::getContext() instead.', E_USER_DEPRECATED); return static::$applicationContext; } diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89631-UseEnvironmentAPIToFetchApplicationContext.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89631-UseEnvironmentAPIToFetchApplicationContext.rst new file mode 100644 index 0000000000000000000000000000000000000000..a4517288e226c00238ac8eac3cd45b4a5b6da273 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89631-UseEnvironmentAPIToFetchApplicationContext.rst @@ -0,0 +1,34 @@ +.. include:: ../../Includes.txt + +====================================================================== +Deprecation: #89631 - Use Environment API to fetch application context +====================================================================== + +See :issue:`89631` + +Description +=========== + +The Environment API, introduced in TYPO3 v9.3, allows access to the current Application Context (Production, Testing or Development). + +The method :php:`GeneralUtility::getApplicationContext()` has been deprecated, as the same information is now available in :php:`TYPO3\CMS\Core\Core\Environment::getContext()`. + + +Impact +====== + +Calling the GeneralUtility method will trigger a PHP deprecation warning. + + +Affected Installations +====================== + +Any TYPO3 installation with a third-party extension calling the method directly. + + +Migration +========= + +Use the Environment API call and substitute the method directly. + +.. index:: PHP-API, FullyScanned, ext:core \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Unit/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcherTest.php b/typo3/sysext/core/Tests/Unit/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcherTest.php index ba488ca30fc93583942fbde3c0083a776d995c94..44d475dc54d7c82872edf32d3a789b6555c8dafc 100644 --- a/typo3/sysext/core/Tests/Unit/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcherTest.php +++ b/typo3/sysext/core/Tests/Unit/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcherTest.php @@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionM use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\DateTimeAspect; use TYPO3\CMS\Core\Core\ApplicationContext; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Http\ServerRequest; use TYPO3\CMS\Core\Package\PackageInterface; use TYPO3\CMS\Core\Package\PackageManager; @@ -35,10 +36,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; */ class AbstractConditionMatcherTest extends UnitTestCase { - /** - * @var ApplicationContext - */ - protected $backupApplicationContext; + protected $backupEnvironment = true; /** * @var AbstractConditionMatcher|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface @@ -78,7 +76,6 @@ class AbstractConditionMatcherTest extends UnitTestCase GeneralUtility::setSingletonInstance(PackageManager::class, $packageManagerProphecy->reveal()); $this->initConditionMatcher(); - $this->backupApplicationContext = GeneralUtility::getApplicationContext(); } protected function initConditionMatcher() @@ -90,15 +87,6 @@ class AbstractConditionMatcherTest extends UnitTestCase $this->conditionMatcher->setLogger(new NullLogger()); } - /** - * Tear down - */ - protected function tearDown(): void - { - Fixtures\GeneralUtilityFixture::setApplicationContext($this->backupApplicationContext); - parent::tearDown(); - } - /** * @return array */ @@ -249,9 +237,18 @@ class AbstractConditionMatcherTest extends UnitTestCase */ public function evaluateConditionCommonReturnsTrueForMatchingContexts($matchingContextCondition): void { - /** @var ApplicationContext $applicationContext */ - $applicationContext = new ApplicationContext('Production/Staging/Server2'); - Fixtures\GeneralUtilityFixture::setApplicationContext($applicationContext); + Environment::initialize( + new ApplicationContext('Production/Staging/Server2'), + true, + false, + Environment::getProjectPath(), + Environment::getPublicPath(), + Environment::getVarPath(), + Environment::getConfigPath(), + Environment::getBackendPath() . '/index.php', + Environment::isWindows() ? 'WINDOWS' : 'UNIX' + ); + $this->initConditionMatcher(); // Test expression language @@ -283,9 +280,17 @@ class AbstractConditionMatcherTest extends UnitTestCase */ public function evaluateConditionCommonReturnsNullForNotMatchingApplicationContexts($notMatchingApplicationContextCondition): void { - /** @var ApplicationContext $applicationContext */ - $applicationContext = new ApplicationContext('Production/Staging/Server2'); - Fixtures\GeneralUtilityFixture::setApplicationContext($applicationContext); + Environment::initialize( + new ApplicationContext('Production/Staging/Server2'), + true, + false, + Environment::getProjectPath(), + Environment::getPublicPath(), + Environment::getVarPath(), + Environment::getConfigPath(), + Environment::getBackendPath() . '/index.php', + Environment::isWindows() ? 'WINDOWS' : 'UNIX' + ); $this->initConditionMatcher(); // Test expression language diff --git a/typo3/sysext/core/Tests/Unit/Configuration/TypoScript/ConditionMatching/Fixtures/GeneralUtilityFixture.php b/typo3/sysext/core/Tests/Unit/Configuration/TypoScript/ConditionMatching/Fixtures/GeneralUtilityFixture.php deleted file mode 100644 index fec5ccc15713a01e413798ff76b57dc3e3c3aedd..0000000000000000000000000000000000000000 --- a/typo3/sysext/core/Tests/Unit/Configuration/TypoScript/ConditionMatching/Fixtures/GeneralUtilityFixture.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -namespace TYPO3\CMS\Core\Tests\Unit\Configuration\TypoScript\ConditionMatching\Fixtures; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -/** - * Fixture for TYPO3\CMS\Core\Utility\GeneralUtility - */ -class GeneralUtilityFixture extends \TYPO3\CMS\Core\Utility\GeneralUtility -{ - /** - * @param \TYPO3\CMS\Core\Core\ApplicationContext $applicationContext - */ - public static function setApplicationContext($applicationContext) - { - static::$applicationContext = $applicationContext; - } -} diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index 98f4ae3cc54aa211003da82a8d71d6c652adf72a..e6af250142d9d873e8a3da18e91d8cda36ea17bf 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -874,7 +874,7 @@ class ContentObjectRenderer implements LoggerAwareInterface $exceptionHandlerClassName = null; $tsfe = $this->getTypoScriptFrontendController(); if (!isset($tsfe->config['config']['contentObjectExceptionHandler'])) { - if (GeneralUtility::getApplicationContext()->isProduction()) { + if (Environment::getContext()->isProduction()) { $exceptionHandlerClassName = '1'; } } else { diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php index e0178c79b8fb5b33218d4e98674182846392b8ad..8316f526bf0e18aef3296c3a1ad040d6b00c0d42 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php @@ -28,6 +28,7 @@ use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\UserAspect; use TYPO3\CMS\Core\Context\WorkspaceAspect; use TYPO3\CMS\Core\Core\ApplicationContext; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Domain\Repository\PageRepository; use TYPO3\CMS\Core\Http\ServerRequest; use TYPO3\CMS\Core\Http\Uri; @@ -131,6 +132,8 @@ class ContentObjectRendererTest extends UnitTestCase */ protected $cacheManager; + protected $backupEnvironment = true; + /** * Set up */ @@ -2346,13 +2349,19 @@ class ContentObjectRendererTest extends UnitTestCase */ public function exceptionHandlerIsEnabledByDefaultInProductionContext(): void { - $backupApplicationContext = GeneralUtility::getApplicationContext(); - Fixtures\GeneralUtilityFixture::setApplicationContext(new ApplicationContext('Production')); - + Environment::initialize( + new ApplicationContext('Production'), + true, + false, + Environment::getProjectPath(), + Environment::getPublicPath(), + Environment::getVarPath(), + Environment::getConfigPath(), + Environment::getBackendPath() . '/index.php', + Environment::isWindows() ? 'WINDOWS' : 'UNIX' + ); $contentObjectFixture = $this->createContentObjectThrowingExceptionFixture(); $this->subject->render($contentObjectFixture, []); - - Fixtures\GeneralUtilityFixture::setApplicationContext($backupApplicationContext); } /** diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/Fixtures/GeneralUtilityFixture.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/Fixtures/GeneralUtilityFixture.php deleted file mode 100644 index d3c4db815c75d3241657094637522f4b9b829c8b..0000000000000000000000000000000000000000 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/Fixtures/GeneralUtilityFixture.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Fixtures; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -/** - * Fixture for TYPO3\CMS\Core\Utility\GeneralUtility - */ -class GeneralUtilityFixture extends \TYPO3\CMS\Core\Utility\GeneralUtility -{ - /** - * @param \TYPO3\CMS\Core\Core\ApplicationContext $applicationContext - */ - public static function setApplicationContext($applicationContext) - { - static::$applicationContext = $applicationContext; - } -} diff --git a/typo3/sysext/install/Classes/Configuration/Context/DebugPreset.php b/typo3/sysext/install/Classes/Configuration/Context/DebugPreset.php index aa0704473e68a1c6921fed4bb1217eee31c0bbea..5983eec7e74a90a204be251af6999aa9607a466d 100644 --- a/typo3/sysext/install/Classes/Configuration/Context/DebugPreset.php +++ b/typo3/sysext/install/Classes/Configuration/Context/DebugPreset.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Configuration\Context; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Install\Configuration; /** @@ -63,9 +64,8 @@ class DebugPreset extends Configuration\AbstractPreset */ public function getPriority() { - $context = \TYPO3\CMS\Core\Utility\GeneralUtility::getApplicationContext(); $priority = $this->priority; - if ($context->isDevelopment()) { + if (Environment::getContext()->isDevelopment()) { $priority = $priority + 20; } return $priority; diff --git a/typo3/sysext/install/Classes/Configuration/Context/LivePreset.php b/typo3/sysext/install/Classes/Configuration/Context/LivePreset.php index 00d86f952eeee1d04d10b9a65ed76d4737c275d4..43e86e54c59be2c1017e862a73909f87ad1400d9 100644 --- a/typo3/sysext/install/Classes/Configuration/Context/LivePreset.php +++ b/typo3/sysext/install/Classes/Configuration/Context/LivePreset.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Configuration\Context; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Install\Configuration; /** @@ -63,9 +64,8 @@ class LivePreset extends Configuration\AbstractPreset */ public function getPriority() { - $context = \TYPO3\CMS\Core\Utility\GeneralUtility::getApplicationContext(); $priority = $this->priority; - if ($context->isProduction()) { + if (Environment::getContext()->isProduction()) { $priority = $priority + 20; } return $priority; diff --git a/typo3/sysext/install/Classes/Controller/InstallerController.php b/typo3/sysext/install/Classes/Controller/InstallerController.php index c9e59d4bd29599379d79f72ba6d6e82503f3e089..b2dbcdbf6482a1642d8ba5ca909dac852b8cbeda 100644 --- a/typo3/sysext/install/Classes/Controller/InstallerController.php +++ b/typo3/sysext/install/Classes/Controller/InstallerController.php @@ -70,7 +70,7 @@ class InstallerController public function initAction(): ResponseInterface { $bust = $GLOBALS['EXEC_TIME']; - if (!GeneralUtility::getApplicationContext()->isDevelopment()) { + if (!Environment::getContext()->isDevelopment()) { $bust = GeneralUtility::hmac(TYPO3_version . Environment::getProjectPath()); } $view = $this->initializeStandaloneView('Installer/Init.html'); diff --git a/typo3/sysext/install/Classes/Controller/LayoutController.php b/typo3/sysext/install/Classes/Controller/LayoutController.php index 21161e69deedafc820e8d8fb675940b22e5c2084..f7a0d9cefb8021fd7d80cf33a7641b212ffabdb9 100644 --- a/typo3/sysext/install/Classes/Controller/LayoutController.php +++ b/typo3/sysext/install/Classes/Controller/LayoutController.php @@ -44,7 +44,7 @@ class LayoutController extends AbstractController public function initAction(ServerRequestInterface $request): ResponseInterface { $bust = $GLOBALS['EXEC_TIME']; - if (!GeneralUtility::getApplicationContext()->isDevelopment()) { + if (!Environment::getContext()->isDevelopment()) { $bust = GeneralUtility::hmac(TYPO3_version . Environment::getProjectPath()); } $view = $this->initializeStandaloneView($request, 'Layout/Init.html'); diff --git a/typo3/sysext/install/Classes/Controller/SettingsController.php b/typo3/sysext/install/Classes/Controller/SettingsController.php index 1a05228bb20c90e13c3ecc7189c74e1af72db384..acedac4b22f12f70b12c99fecb8e76bde5e08b62 100644 --- a/typo3/sysext/install/Classes/Controller/SettingsController.php +++ b/typo3/sysext/install/Classes/Controller/SettingsController.php @@ -21,6 +21,7 @@ use TYPO3\CMS\Core\Configuration\ConfigurationManager; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader; use TYPO3\CMS\Core\Core\Bootstrap; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; @@ -134,7 +135,7 @@ class SettingsController extends AbstractController $formProtection = FormProtectionFactory::get(InstallToolFormProtection::class); $view->assignMultiple([ 'systemMaintainerWriteToken' => $formProtection->generateToken('installTool', 'systemMaintainerWrite'), - 'systemMaintainerIsDevelopmentContext' => GeneralUtility::getApplicationContext()->isDevelopment(), + 'systemMaintainerIsDevelopmentContext' => Environment::getContext()->isDevelopment(), ]); $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php index 7c462d7550a35070c5bca77f4d68db7fa9746fb3..5a1ae70f1a45f984e6c0d84752253fe67e09744b 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php @@ -938,4 +938,11 @@ return [ 'Deprecation-88995-CallingRegisterPluginWithVendorName.rst' ], ], + 'TYPO3\CMS\Core\Utility\GeneralUtility::getApplicationContext' => [ + 'numberOfMandatoryArguments' => 0, + 'maximumNumberOfArguments' => 0, + 'restFiles' => [ + 'Deprecation-89631-UseEnvironmentAPIToFetchApplicationContext.rst' + ], + ], ];