[FEATURE] Introduce an Environment API class 60/55960/6
authorBenni Mack <benni@typo3.org>
Thu, 1 Mar 2018 07:07:22 +0000 (08:07 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Wed, 7 Mar 2018 10:01:01 +0000 (11:01 +0100)
A new class Environment is added, which is initialized right at the very
beginning of any TYPO3-based request.

The class contains a static list of properties commonly used throughout the
core to access paths, constants or global variables. The class also contains
methods that are relevant for ALL kind of PHP requests, CLI and web requests.

In order to avoid constants, and global variables, this is centralized in one
place, which allows to "re-define" values for testing purposes, making functional
tests a lot simpler.

This would better be stored in a dependency injection container and injected
as dependency/parameter into the respective classes that need the information.
We're not at that point to use dependency injection for every class, therefore
this class provides a static interface as a long-term interim solution.

Additionally, it adds a new functionality, basically finally allowing to move
code outside of the PATH_site constant with a proper API.

If the environment variable "TYPO3_PATH_APP" is set, this acts as a root path
for the project, which can be the same as PATH_site, or (usually) one level
up.
All typical new composer-based installations have this folder structure set up
automatically. Non-composer mode installations can set this environment variable
to make TYPO3 aware of non-public-accessable folders.

The following changes apply (with further patches):
- When TYPO3_PATH_APP is set, all logs / sessions / cache files are moved into $PROJECT_ROOT/var/.
- Same applies to typo3conf/l10n/, effectively moving this into a semi-writable
place, the same place where logs should be placed.
- LocalConfiguration.php, PackageStates.php and AdditionalConfiguration.php
  are now located at $PROJECT_ROOT/config/

The folder typo3conf then only contains code related to extensions.

The long-term goal until 9 LTS is that TYPO3 Core does not use any constants
anymore, which have been superseded by this class right now.

Resolves: #84153
Releases: master
Change-Id: I7ca35f752493d7e0d1c21c83a9ffbfb6a40eb463
Reviewed-on: https://review.typo3.org/55960
Reviewed-by: Benjamin Franzke <bfr@qbus.de>
Tested-by: Benjamin Franzke <bfr@qbus.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
16 files changed:
typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Core/Environment.php [new file with mode: 0644]
typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/core/Documentation/Changelog/master/Feature-84153-IntroduceAGenericEnvironmentClass.rst [new file with mode: 0644]
typo3/sysext/core/ext_localconf.php
typo3/sysext/extensionmanager/Classes/Command/ExtensionCommandController.php
typo3/sysext/extensionmanager/Classes/Controller/AbstractModuleController.php
typo3/sysext/extensionmanager/Classes/Controller/ListController.php
typo3/sysext/extensionmanager/Classes/Controller/UploadExtensionFileController.php
typo3/sysext/extensionmanager/Classes/Utility/Connection/TerUtility.php
typo3/sysext/install/Classes/Controller/InstallerController.php
typo3/sysext/install/Classes/Controller/MaintenanceController.php
typo3/sysext/install/Classes/Controller/UpgradeController.php
typo3/sysext/install/Classes/Service/CoreUpdateService.php

index 3669eb8..197b840 100644 (file)
@@ -18,7 +18,7 @@ use Psr\Http\Message\ResponseInterface;
 use TYPO3\CMS\Backend\Routing\UriBuilder;
 use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus;
 use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
-use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Http\HtmlResponse;
@@ -165,7 +165,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
      */
     protected function getComposerMode()
     {
-        if (!Bootstrap::usesComposerClassLoading()) {
+        if (!Environment::isComposerMode()) {
             return;
         }
 
index 810322a..3611cbc 100644 (file)
@@ -58,11 +58,6 @@ class Bootstrap
     protected $earlyInstances = [];
 
     /**
-     * @var bool
-     */
-    protected static $usesComposerClassLoading = false;
-
-    /**
      * Disable direct creation of this object.
      * Set unique requestId and the application context
      *
@@ -79,7 +74,7 @@ class Bootstrap
      */
     public static function usesComposerClassLoading()
     {
-        return self::$usesComposerClassLoading;
+        return Environment::isComposerMode();
     }
 
     /**
@@ -162,7 +157,8 @@ class Bootstrap
         }
         GeneralUtility::presetApplicationContext($this->applicationContext);
         SystemEnvironmentBuilder::run($entryPointLevel);
-        if (!self::$usesComposerClassLoading && ClassLoadingInformation::isClassLoadingInformationAvailable()) {
+        SystemEnvironmentBuilder::initializeEnvironment($this->applicationContext);
+        if (!Environment::isComposerMode() && ClassLoadingInformation::isClassLoadingInformationAvailable()) {
             ClassLoadingInformation::registerClassLoadingInformation();
         }
         return $this;
@@ -179,9 +175,6 @@ class Bootstrap
     {
         $this->setEarlyInstance(\Composer\Autoload\ClassLoader::class, $classLoader);
         ClassLoadingInformation::setClassLoader($classLoader);
-        if (defined('TYPO3_COMPOSER_MODE') && TYPO3_COMPOSER_MODE) {
-            self::$usesComposerClassLoading = true;
-        }
 
         /** @see initializeAnnotationRegistry */
         AnnotationRegistry::registerLoader([$classLoader, 'loadClass']);
diff --git a/typo3/sysext/core/Classes/Core/Environment.php b/typo3/sysext/core/Classes/Core/Environment.php
new file mode 100644 (file)
index 0000000..4db7cdc
--- /dev/null
@@ -0,0 +1,206 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Core\Core;
+
+/*
+ * 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!
+ */
+
+/**
+ * This class is initialized once in the SystemEnvironmentBuilder, and can then
+ * be used throughout the application to access common variables
+ * related to path-resolving and OS-/PHP-application specific information.
+ *
+ * It's main design goal is to remove any access to constants within TYPO3 code and to provide a static,
+ * for TYPO3 core and extensions non-changeable information.
+ *
+ * This class does not contain any HTTP related information, as this is handled in NormalizedParams functionality.
+ *
+ * All path-related methods do return the realpath to the paths without (!) the trailing slash.
+ *
+ * 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 "PATH_site" call "Environment::getPublicPath() . '/'"
+ * Instead of writing "TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI" call "Environment::isCli()"
+ */
+class Environment
+{
+    protected static $cli;
+    protected static $composerMode;
+    protected static $context;
+    protected static $projectPath;
+    protected static $publicPath;
+    protected static $currentScript;
+    protected static $os;
+    protected static $varPath;
+    protected static $configPath;
+
+    /**
+     * Sets up the Environment. Please note that this is not public API and only used within the very early
+     * Set up of TYPO3, or to be used within tests. If you ever call this method in your extension, you're probably
+     * doing something wrong. Never call this method! Never rely on it!
+     *
+     * @param ApplicationContext $context
+     * @param bool $cli
+     * @param bool $composerMode
+     * @param string $projectPath
+     * @param string $publicPath
+     * @param string $varPath
+     * @param string $configPath
+     * @param string $currentScript
+     * @param string $os
+     * @private
+     */
+    public static function initialize(
+        ApplicationContext $context,
+        bool $cli,
+        bool $composerMode,
+        string $projectPath,
+        string $publicPath,
+        string $varPath,
+        string $configPath,
+        string $currentScript,
+        string $os
+    ) {
+        self::$cli = $cli;
+        self::$composerMode = $composerMode;
+        self::$context = $context;
+        self::$projectPath = $projectPath;
+        self::$publicPath = $publicPath;
+        self::$varPath = $varPath;
+        self::$configPath = $configPath;
+        self::$currentScript = $currentScript;
+        self::$os = $os;
+    }
+
+    /**
+     * Delivers the ApplicationContext object, usually defined in TYPO3_CONTEXT environment variables.
+     * This is something like "Production", "Testing", or "Development" or any additional information
+     * "Production/Staging".
+     *
+     * @return ApplicationContext
+     */
+    public static function getContext(): ApplicationContext
+    {
+        return self::$context;
+    }
+
+    /**
+     * Informs whether TYPO3 has been installed via composer or not. Typically this is useful inside the
+     * Maintenance Modules, or the Extension Manager.
+     *
+     * @return bool
+     */
+    public static function isComposerMode(): bool
+    {
+        return self::$composerMode;
+    }
+
+    /**
+     * Whether the current PHP request is handled by a CLI SAPI module or not.
+     *
+     * @return bool
+     */
+    public static function isCli(): bool
+    {
+        return self::$cli;
+    }
+
+    /**
+     * The root path to the project. For installations set up via composer, this is the path where your
+     * composer.json file is stored. For non-composer-setups, this is (due to legacy reasons) the public web folder
+     * where the TYPO3 installation has been unzipped (something like htdocs/ or public/ on your webfolder).
+     * However, non-composer-mode installations define an environment variable called "TYPO3_PATH_APP"
+     * to define a different folder (usually a parent folder) to allow TYPO3 to access and store data outside
+     * of the public web folder.
+     *
+     * @return string The absolute path to the project without the trailing slash
+     */
+    public static function getProjectPath(): string
+    {
+        return self::$projectPath;
+    }
+
+    /**
+     * The public web folder where index.php (= the frontend application) is put. This is equal to the legacy constant
+     * PATH_site, without the trailing slash. For non-composer installations, the project path = the public path.
+     *
+     * @return string
+     */
+    public static function getPublicPath(): string
+    {
+        return self::$publicPath;
+    }
+
+    /**
+     * The folder where variable data like logs, sessions, locks, and cache files can be stored.
+     * When project path = public path, then this folder is usually typo3temp/var/, otherwise it's set to
+     * $project_path/var.
+     *
+     * @return string
+     */
+    public static function getVarPath(): string
+    {
+        return self::$varPath;
+    }
+
+    /**
+     * The folder where all global (= installation-wide) configuration like
+     * - LocalConfiguration.php,
+     * - AdditionalConfiguration.php, and
+     * - PackageStates.php
+     * is put.
+     * This folder usually has to be writable for TYPO3 in order to work.
+     *
+     * When project path = public path, then this folder is usually typo3conf/, otherwise it's set to
+     * $project_path/config.
+     *
+     * @return string
+     */
+    public static function getConfigPath(): string
+    {
+        return self::$configPath;
+    }
+
+    /**
+     * The path + filename to the current PHP script.
+     *
+     * @return string
+     */
+    public static function getCurrentScript(): string
+    {
+        return self::$currentScript;
+    }
+
+    /**
+     * Whether this TYPO3 installation runs on windows
+     *
+     * @return bool
+     */
+    public static function isWindows(): bool
+    {
+        return self::$os === 'WINDOWS';
+    }
+
+    /**
+     * Whether this TYPO3 installation runs on unix (= non-windows machines)
+     *
+     * @return bool
+     */
+    public static function isUnix(): bool
+    {
+        return self::$os === 'UNIX';
+    }
+}
index 1961bb4..0f6413a 100644 (file)
@@ -229,6 +229,29 @@ class SystemEnvironmentBuilder
     }
 
     /**
+     * Initialize the Environment class
+     *
+     * @param ApplicationContext $context
+     */
+    public static function initializeEnvironment(ApplicationContext $context)
+    {
+        $sitePath = rtrim(PATH_site, '/');
+        $projectRootPath = getenv('TYPO3_PATH_APP');
+        $isDifferentRootPath = ($projectRootPath && $projectRootPath !== $sitePath);
+        Environment::initialize(
+            $context,
+            PHP_SAPI === 'cli',
+            self::usesComposerClassLoading(),
+            $isDifferentRootPath ? $projectRootPath : $sitePath,
+            $sitePath,
+            $isDifferentRootPath ? $projectRootPath . '/var'    : $sitePath . '/typo3temp/var',
+            $isDifferentRootPath ? $projectRootPath . '/config' : $sitePath . '/typo3conf',
+            PATH_thisScript,
+            self::getTypo3Os() === 'WIN' ? 'WINDOWS' : 'UNIX'
+        );
+    }
+
+    /**
      * Initialize basic error reporting.
      *
      * There are a lot of extensions that have no strict / notice / deprecated free
index 64b4eab..488910e 100644 (file)
@@ -18,8 +18,8 @@ use Symfony\Component\Finder\Finder;
 use Symfony\Component\Finder\SplFileInfo;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement;
-use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Core\ClassLoadingInformation;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -613,7 +613,7 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
      */
     protected function registerTransientClassLoadingInformationForPackage(PackageInterface $package)
     {
-        if (Bootstrap::usesComposerClassLoading()) {
+        if (Environment::isComposerMode()) {
             return;
         }
         ClassLoadingInformation::registerTransientClassLoadingInformationForPackage($package);
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-84153-IntroduceAGenericEnvironmentClass.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-84153-IntroduceAGenericEnvironmentClass.rst
new file mode 100644 (file)
index 0000000..d129b5e
--- /dev/null
@@ -0,0 +1,45 @@
+.. include:: ../../Includes.txt
+
+=======================================================
+Feature: #84153 - Introduce a generic Environment class
+=======================================================
+
+See :issue:`84153`
+
+Description
+===========
+
+A new base API class :php:`TYPO3\CMS\Core\Core\Environment` has been added. This class contains application-wide
+information related to paths and PHP internals, which were previously exposed via PHP constants.
+
+This Environment class comes with a new possibility, to have a `config` and `var` folder outside of
+the document root (known as `PATH_site`). When the environment variable :php:`TYPO3_PATH_APP` is set, which
+defines the project root folder, the new `config` and `var` folders outside of the document root are used for
+installation-wide configuration and volatile files.
+
+The following static API methods are exposed within the Environment class:
+
+- `Environment::isCli()` - defines whether TYPO3 runs on a CLI context or HTTP context
+- `Environment::getApplicationContext()` - returns the ApplicationContext object that encapsulates `TYPO3_CONTEXT`
+- `Environment::isComposerMode()` - defines whether TYPO3 was installed via composer
+- `Environment::getProjectPath()` - returns the absolute path to the root-level folder without the trailing slash
+- `Environment::getPublicPath()` - returns the absolute path to the publically accessible folder (previously known as PATH_site) without the trailing slash
+- `Environment::getVarPath()` - returns the absolute path to the folder where non-public semi-persistent files can be stored. For regular projects, this is known as PATH_site/typo3temp/var
+- `Environment::getConfigPath()` - returns the absolute path to the folder where (writeable) configuration is stored. For regular projects, this is known as PATH_site/typo3conf
+- `Environment::getCurrentScript()` - the absolute path and filename to the currently executed PHP script
+- `Environment::isWindows()` - whether TYPO3 runs on a windows server
+- `Environment::isUnix()` - whether TYPO3 runs on a unix server
+
+
+Impact
+======
+
+You should not rely on the PHP constants anymore, but rather use the Environment class to resolve paths:
+- :php:`PATH_site`
+- :php:`PATH_typo3conf`
+- :php:`PATH_site . 'typo3temp/var/'`
+- :php:`TYPO3_OS`
+- :php:`TYPO3_REQUESTTYPE_CLI`
+- :php:`PATH_thisScript`
+
+.. index:: PHP-API
\ No newline at end of file
index 5596b55..74c2081 100644 (file)
@@ -48,7 +48,7 @@ $signalSlotDispatcher->connect(
     'cleanupProcessedFilesPostFileReplace'
 );
 
-if (!\TYPO3\CMS\Core\Core\Bootstrap::usesComposerClassLoading()) {
+if (!\TYPO3\CMS\Core\Core\Environment::isComposerMode()) {
     $signalSlotDispatcher->connect(
         \TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class,
         'afterExtensionInstall',
index f878822..b972138 100644 (file)
@@ -14,8 +14,8 @@ namespace TYPO3\CMS\Extensionmanager\Command;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Core\ClassLoadingInformation;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
 
 /**
@@ -85,7 +85,7 @@ class ExtensionCommandController extends CommandController
      */
     public function dumpClassLoadingInformationCommand()
     {
-        if (Bootstrap::usesComposerClassLoading()) {
+        if (Environment::isComposerMode()) {
             $this->output->outputLine('<error>Class loading information is managed by composer. Use "composer dump-autoload" command to update the information.</error>');
             $this->quit(1);
         } else {
index 9e4b4f5..367baa9 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Extensionmanager\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 use TYPO3\CMS\Backend\View\BackendTemplateView;
-use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
 
 /**
@@ -66,7 +66,7 @@ class AbstractModuleController extends AbstractController
             ]
         ];
 
-        if (!$this->settings['offlineMode'] && !Bootstrap::usesComposerClassLoading()) {
+        if (!$this->settings['offlineMode'] && !Environment::isComposerMode()) {
             $menuItems['getExtensions'] = [
                 'controller' => 'List',
                 'action' => 'ter',
index ee20152..1514786 100644 (file)
@@ -17,7 +17,7 @@ namespace TYPO3\CMS\Extensionmanager\Controller;
 use TYPO3\CMS\Backend\Template\Components\ButtonBar;
 use TYPO3\CMS\Backend\View\BackendTemplateView;
 use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
-use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
@@ -117,7 +117,7 @@ class ListController extends AbstractModuleController
      */
     protected function addComposerModeNotification()
     {
-        if (Bootstrap::usesComposerClassLoading()) {
+        if (Environment::isComposerMode()) {
             $this->addFlashMessage(
                 LocalizationUtility::translate(
                     'composerMode.message',
@@ -253,7 +253,7 @@ class ListController extends AbstractModuleController
      */
     protected function registerDocheaderButtons()
     {
-        if (Bootstrap::usesComposerClassLoading()) {
+        if (Environment::isComposerMode()) {
             return;
         }
 
index 0daa0a8..cc03973 100644 (file)
@@ -15,7 +15,7 @@ namespace TYPO3\CMS\Extensionmanager\Controller;
  */
 
 use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
-use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extensionmanager\Exception\DependencyConfigurationNotFoundException;
@@ -102,7 +102,7 @@ class UploadExtensionFileController extends AbstractController
      */
     public function formAction()
     {
-        if (Bootstrap::usesComposerClassLoading()) {
+        if (Environment::isComposerMode()) {
             throw new ExtensionManagerException(
                 'Composer mode is active. You are not allowed to upload any extension file.',
                 1444725828
@@ -118,7 +118,7 @@ class UploadExtensionFileController extends AbstractController
      */
     public function extractAction($overwrite = false)
     {
-        if (Bootstrap::usesComposerClassLoading()) {
+        if (Environment::isComposerMode()) {
             throw new ExtensionManagerException(
                 'Composer mode is active. You are not allowed to upload any extension file.',
                 1444725853
index 59a6759..05b54af 100644 (file)
@@ -15,7 +15,7 @@ namespace TYPO3\CMS\Extensionmanager\Utility\Connection;
  */
 
 use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
-use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
 
@@ -45,7 +45,7 @@ class TerUtility
     {
         if (
             (bool)GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('extensionmanager', 'offlineMode')
-            || Bootstrap::usesComposerClassLoading()
+            || Environment::isComposerMode()
         ) {
             throw new ExtensionManagerException('Extension Manager is in offline mode. No TER connection available.', 1437078620);
         }
index 323aeea..07b2d6d 100644 (file)
@@ -22,6 +22,7 @@ use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
 use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
 use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Schema\Exception\StatementException;
@@ -663,7 +664,7 @@ class InstallerController
         $view = $this->initializeStandaloneView('Installer/ShowDefaultConfiguration.html');
         $formProtection = FormProtectionFactory::get(InstallToolFormProtection::class);
         $view->assignMultiple([
-            'composerMode' => Bootstrap::usesComposerClassLoading(),
+            'composerMode' => Environment::isComposerMode(),
             'executeDefaultConfigurationToken' => $formProtection->generateToken('installTool', 'executeDefaultConfiguration'),
         ]);
         return new JsonResponse([
index 916d57a..d74f6c5 100644 (file)
@@ -18,8 +18,8 @@ namespace TYPO3\CMS\Install\Controller;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
-use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Core\ClassLoadingInformation;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Schema\Exception\StatementException;
 use TYPO3\CMS\Core\Database\Schema\SchemaMigrator;
@@ -143,7 +143,7 @@ class MaintenanceController extends AbstractController
     public function dumpAutoloadAction(): ResponseInterface
     {
         $messageQueue = new FlashMessageQueue('install');
-        if (Bootstrap::usesComposerClassLoading()) {
+        if (Environment::isComposerMode()) {
             $messageQueue->enqueue(new FlashMessage(
                 '',
                 'Skipped generating additional class loading information in composer mode.',
index af59fe5..46d49ea 100644 (file)
@@ -23,6 +23,7 @@ use Psr\Http\Message\ServerRequestInterface;
 use Symfony\Component\Finder\Finder;
 use Symfony\Component\Finder\SplFileInfo;
 use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
 use TYPO3\CMS\Core\FormProtection\InstallToolFormProtection;
@@ -180,7 +181,7 @@ class UpgradeController extends AbstractController
             'extensionCompatTesterUninstallToken' => $formProtection->generateToken('installTool', 'extensionCompatTesterUninstallExtension'),
 
             'coreUpdateEnabled' => $coreUpdateService->isCoreUpdateEnabled(),
-            'coreUpdateComposerMode' => Bootstrap::usesComposerClassLoading(),
+            'coreUpdateComposerMode' => Environment::isComposerMode(),
             'coreUpdateIsReleasedVersion' => $coreVersionService->isInstalledVersionAReleasedVersion(),
             'coreUpdateIsSymLinkedCore' => is_link(PATH_site . 'typo3_src'),
 
index 9c4fa3d..88c44f1 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Install\Service;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
@@ -87,7 +87,7 @@ class CoreUpdateService
     public function isCoreUpdateEnabled()
     {
         $coreUpdateDisabled = getenv('TYPO3_DISABLE_CORE_UPDATER') ?: (getenv('REDIRECT_TYPO3_DISABLE_CORE_UPDATER') ?: false);
-        return !Bootstrap::usesComposerClassLoading() && !$coreUpdateDisabled;
+        return !Environment::isComposerMode() && !$coreUpdateDisabled;
     }
 
     /**