From eabae6ab0e0270301b9b83d211a25fe3b7f7c067 Mon Sep 17 00:00:00 2001
From: Benjamin Franzke <bfr@qbus.de>
Date: Sat, 17 Feb 2018 16:00:58 +0100
Subject: [PATCH] [TASK] Make stateless Bootstrap methods static

Methods that do not use $this but mainly act as utility
may be used statically.
The previous non-static chainable behaviour is preserved
by returning static::$instance. (Invoking a static method
non statically does not trigger E_NOTICE or alike.)

The motivation for this change is to deprecate the
Bootstrap instanciated usage at some (later) point
in order to reduce global state.

The following methods are affected:
 * initializeLanguageObject
 * initializeBackendAuthentication
 * initializeBackendUser
 * initializeBackendRouter
 * loadExtTables
 * loadBaseTca
 * loadTypo3LoadedExtAndExtLocalconf
 * unsetReservedGlobalVariables
 * startOutputBuffering
 * disableCoreCache

Releases: master
Resolves: #83952
Change-Id: I59d3027c5d10326d7bab2ae02e6ff0eb836f23e4
Reviewed-on: https://review.typo3.org/55775
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
---
 .../Command/ReferenceIndexUpdateCommand.php   |  2 +-
 .../Middleware/BackendRouteInitialization.php |  5 +-
 .../Middleware/BackendUserAuthenticator.php   |  9 ++-
 .../FormInlineAjaxControllerTest.php          |  2 +-
 .../Page/LocalizationControllerTest.php       |  2 +-
 .../LocalizationRepositoryTest.php            |  2 +-
 .../Classes/Console/CommandApplication.php    |  2 +-
 .../Classes/Console/CommandRequestHandler.php | 22 ++-----
 typo3/sysext/core/Classes/Core/Bootstrap.php  | 64 +++++++++----------
 .../AbstractDataHandlerActionTestCase.php     |  2 +-
 .../Classes/Utility/InstallUtility.php        |  5 +-
 .../Middleware/BackendUserAuthenticator.php   |  7 +-
 .../impexp/Classes/Command/ImportCommand.php  |  2 +-
 .../AbstractImportExportTestCase.php          |  2 +-
 .../Classes/Controller/AbstractController.php |  9 ++-
 .../Controller/InstallerController.php        |  9 ++-
 .../Classes/Controller/SettingsController.php |  2 +-
 .../Classes/Service/ClearCacheService.php     | 12 ++--
 .../Classes/Command/CleanFlexFormsCommand.php |  2 +-
 .../Classes/Command/DeletedRecordsCommand.php |  2 +-
 .../FilesWithMultipleReferencesCommand.php    |  2 +-
 .../Classes/Command/LostFilesCommand.php      |  2 +-
 .../Classes/Command/MissingFilesCommand.php   |  2 +-
 .../Command/MissingRelationsCommand.php       |  2 +-
 .../Classes/Command/OrphanRecordsCommand.php  |  2 +-
 .../Classes/Command/RteImagesCommand.php      |  2 +-
 .../Recycle/AbstractRecycleTestCase.php       |  2 +-
 .../Classes/Command/SchedulerCommand.php      |  2 +-
 .../WorkspaceVersionRecordsCommand.php        |  2 +-
 .../ActionHandler/ActionHandlerTest.php       |  2 +-
 .../Service/WorkspaceServiceTest.php          |  2 +-
 31 files changed, 85 insertions(+), 101 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Command/ReferenceIndexUpdateCommand.php b/typo3/sysext/backend/Classes/Command/ReferenceIndexUpdateCommand.php
index b516e5e2bc48..f9fc7fe591b1 100644
--- a/typo3/sysext/backend/Classes/Command/ReferenceIndexUpdateCommand.php
+++ b/typo3/sysext/backend/Classes/Command/ReferenceIndexUpdateCommand.php
@@ -49,7 +49,7 @@ class ReferenceIndexUpdateCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $isTestOnly = $input->getOption('check');
         $isSilent = $output->getVerbosity() !== OutputInterface::VERBOSITY_QUIET;
diff --git a/typo3/sysext/backend/Classes/Middleware/BackendRouteInitialization.php b/typo3/sysext/backend/Classes/Middleware/BackendRouteInitialization.php
index cccf3ce06640..8495c9d42ec9 100644
--- a/typo3/sysext/backend/Classes/Middleware/BackendRouteInitialization.php
+++ b/typo3/sysext/backend/Classes/Middleware/BackendRouteInitialization.php
@@ -63,9 +63,8 @@ class BackendRouteInitialization implements MiddlewareInterface
                 . ' to use the TYPO3 API.', E_USER_DEPRECATED);
         }
 
-        Bootstrap::getInstance()
-            ->initializeBackendRouter()
-            ->loadExtTables();
+        Bootstrap::initializeBackendRouter();
+        Bootstrap::loadExtTables();
 
         // Add the route path to the request
         $request = $request->withAttribute('routePath', $pathToRoute);
diff --git a/typo3/sysext/backend/Classes/Middleware/BackendUserAuthenticator.php b/typo3/sysext/backend/Classes/Middleware/BackendUserAuthenticator.php
index 926fe0d79887..2566d33b672d 100644
--- a/typo3/sysext/backend/Classes/Middleware/BackendUserAuthenticator.php
+++ b/typo3/sysext/backend/Classes/Middleware/BackendUserAuthenticator.php
@@ -53,11 +53,10 @@ class BackendUserAuthenticator implements MiddlewareInterface
     {
         $pathToRoute = $request->getAttribute('routePath', '/login');
 
-        Bootstrap::getInstance()
-            ->initializeBackendUser()
-            // @todo: once this logic is in this method, the redirect URL should be handled as response here
-            ->initializeBackendAuthentication($this->isLoggedInBackendUserRequired($pathToRoute))
-            ->initializeLanguageObject();
+        Bootstrap::initializeBackendUser();
+        // @todo: once this logic is in this method, the redirect URL should be handled as response here
+        Bootstrap::initializeBackendAuthentication($this->isLoggedInBackendUserRequired($pathToRoute));
+        Bootstrap::initializeLanguageObject();
 
         return $handler->handle($request);
     }
diff --git a/typo3/sysext/backend/Tests/Functional/Controller/FormInlineAjaxControllerTest.php b/typo3/sysext/backend/Tests/Functional/Controller/FormInlineAjaxControllerTest.php
index 0c06968624c0..0e54d0cc93ad 100644
--- a/typo3/sysext/backend/Tests/Functional/Controller/FormInlineAjaxControllerTest.php
+++ b/typo3/sysext/backend/Tests/Functional/Controller/FormInlineAjaxControllerTest.php
@@ -50,7 +50,7 @@ class FormInlineAjaxControllerTest extends FunctionalTestCase
         $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Fixtures/tx_irretutorial_1ncsv_hotel.xml');
 
         $this->setUpBackendUserFromFixture(1);
-        Bootstrap::getInstance()->initializeLanguageObject();
+        Bootstrap::initializeLanguageObject();
 
         $this->subject = new FormInlineAjaxController();
     }
diff --git a/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php b/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php
index 509231f8ee4f..4970cb65f6c6 100644
--- a/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php
+++ b/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php
@@ -58,7 +58,7 @@ class LocalizationControllerTest extends \TYPO3\TestingFramework\Core\Functional
         $this->backendUser = $this->setUpBackendUserFromFixture(1);
         $this->backendUser->workspace = 0;
 
-        Bootstrap::getInstance()->initializeLanguageObject();
+        Bootstrap::initializeLanguageObject();
         $this->actionService = GeneralUtility::makeInstance(ActionService::class);
 
         $this->importDataSet(__DIR__ . '/Fixtures/pages.xml');
diff --git a/typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/LocalizationRepositoryTest.php b/typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/LocalizationRepositoryTest.php
index 70d42be6e26e..5c1229993662 100644
--- a/typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/LocalizationRepositoryTest.php
+++ b/typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/LocalizationRepositoryTest.php
@@ -35,7 +35,7 @@ class LocalizationRepositoryTest extends \TYPO3\TestingFramework\Core\Functional
         parent::setUp();
 
         $this->setUpBackendUserFromFixture(1);
-        Bootstrap::getInstance()->initializeLanguageObject();
+        Bootstrap::initializeLanguageObject();
 
         $this->importCSVDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/Fixtures/DefaultPagesAndContent.csv');
 
diff --git a/typo3/sysext/core/Classes/Console/CommandApplication.php b/typo3/sysext/core/Classes/Console/CommandApplication.php
index 22ee47e1120a..93d6a2c0502e 100644
--- a/typo3/sysext/core/Classes/Console/CommandApplication.php
+++ b/typo3/sysext/core/Classes/Console/CommandApplication.php
@@ -60,7 +60,7 @@ class CommandApplication implements ApplicationInterface
      */
     public function run(callable $execute = null)
     {
-        $handler = GeneralUtility::makeInstance(CommandRequestHandler::class, $this->bootstrap);
+        $handler = GeneralUtility::makeInstance(CommandRequestHandler::class);
         $handler->handleRequest(new ArgvInput());
 
         if ($execute !== null) {
diff --git a/typo3/sysext/core/Classes/Console/CommandRequestHandler.php b/typo3/sysext/core/Classes/Console/CommandRequestHandler.php
index ba9ce3c7d15d..acc1662c0e19 100644
--- a/typo3/sysext/core/Classes/Console/CommandRequestHandler.php
+++ b/typo3/sysext/core/Classes/Console/CommandRequestHandler.php
@@ -28,12 +28,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  */
 class CommandRequestHandler implements RequestHandlerInterface
 {
-    /**
-     * Instance of the current TYPO3 bootstrap
-     * @var Bootstrap
-     */
-    protected $bootstrap;
-
     /**
      * Instance of the symfony application
      * @var Application
@@ -41,13 +35,10 @@ class CommandRequestHandler implements RequestHandlerInterface
     protected $application;
 
     /**
-     * Constructor handing over the bootstrap
-     *
-     * @param Bootstrap $bootstrap
+     * Constructor initializing the symfony application
      */
-    public function __construct(Bootstrap $bootstrap)
+    public function __construct()
     {
-        $this->bootstrap = $bootstrap;
         $this->application = new Application('TYPO3 CMS', TYPO3_version);
     }
 
@@ -60,11 +51,10 @@ class CommandRequestHandler implements RequestHandlerInterface
     {
         $output = new ConsoleOutput();
 
-        $this->bootstrap
-            ->loadExtTables()
-            // create the BE_USER object (not logged in yet)
-            ->initializeBackendUser(CommandLineUserAuthentication::class)
-            ->initializeLanguageObject();
+        Bootstrap::loadExtTables();
+        // create the BE_USER object (not logged in yet)
+        Bootstrap::initializeBackendUser(CommandLineUserAuthentication::class);
+        Bootstrap::initializeLanguageObject();
         // Make sure output is not buffered, so command-line output and interaction can take place
         ob_clean();
 
diff --git a/typo3/sysext/core/Classes/Core/Bootstrap.php b/typo3/sysext/core/Classes/Core/Bootstrap.php
index d0d650937435..7acbee8a8c5f 100644
--- a/typo3/sysext/core/Classes/Core/Bootstrap.php
+++ b/typo3/sysext/core/Classes/Core/Bootstrap.php
@@ -110,13 +110,13 @@ class Bootstrap
      * Prevent any unwanted output that may corrupt AJAX/compression.
      * This does not interfere with "die()" or "echo"+"exit()" messages!
      *
-     * @return Bootstrap
+     * @return Bootstrap|null
      * @internal This is not a public API method, do not use in own extensions
      */
-    public function startOutputBuffering()
+    public static function startOutputBuffering()
     {
         ob_start();
-        return $this;
+        return static::$instance;
     }
 
     /**
@@ -337,13 +337,13 @@ class Bootstrap
      * Load ext_localconf of extensions
      *
      * @param bool $allowCaching
-     * @return Bootstrap
+     * @return Bootstrap|null
      * @internal This is not a public API method, do not use in own extensions
      */
-    public function loadTypo3LoadedExtAndExtLocalconf($allowCaching = true)
+    public static function loadTypo3LoadedExtAndExtLocalconf($allowCaching = true)
     {
         ExtensionManagementUtility::loadExtLocalconf($allowCaching);
-        return $this;
+        return static::$instance;
     }
 
     /**
@@ -368,15 +368,15 @@ class Bootstrap
     /**
      * Set cache_core to null backend, effectively disabling eg. the cache for ext_localconf and PackageManager etc.
      *
-     * @return \TYPO3\CMS\Core\Core\Bootstrap
+     * @return Bootstrap|null
      * @internal This is not a public API method, do not use in own extensions
      */
-    public function disableCoreCache()
+    public static function disableCoreCache()
     {
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_core']['backend']
             = \TYPO3\CMS\Core\Cache\Backend\NullBackend::class;
         unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_core']['options']);
-        return $this;
+        return static::$instance;
     }
 
     /**
@@ -545,10 +545,10 @@ class Bootstrap
      * Unsetting reserved global variables:
      * Those are set in "ext:core/ext_tables.php" file:
      *
-     * @return Bootstrap
+     * @return Bootstrap|null
      * @internal This is not a public API method, do not use in own extensions
      */
-    public function unsetReservedGlobalVariables()
+    public static function unsetReservedGlobalVariables()
     {
         unset($GLOBALS['PAGES_TYPES']);
         unset($GLOBALS['TCA']);
@@ -559,7 +559,7 @@ class Bootstrap
         unset($GLOBALS['TBE_MODULES_EXT']);
         unset($GLOBALS['TCA_DESCR']);
         unset($GLOBALS['LOCAL_LANG']);
-        return $this;
+        return static::$instance;
     }
 
     /**
@@ -568,13 +568,13 @@ class Bootstrap
      * This will mainly set up $TCA through extMgm API.
      *
      * @param bool $allowCaching True, if loading TCA from cache is allowed
-     * @return Bootstrap
+     * @return Bootstrap|null
      * @internal This is not a public API method, do not use in own extensions
      */
-    public function loadBaseTca(bool $allowCaching = true): Bootstrap
+    public static function loadBaseTca(bool $allowCaching = true)
     {
         ExtensionManagementUtility::loadBaseTca($allowCaching);
-        return $this;
+        return static::$instance;
     }
 
     /**
@@ -584,14 +584,14 @@ class Bootstrap
      * or the according cache file if exists.
      *
      * @param bool $allowCaching True, if reading compiled ext_tables file from cache is allowed
-     * @return Bootstrap
+     * @return Bootstrap|null
      * @internal This is not a public API method, do not use in own extensions
      */
-    public function loadExtTables(bool $allowCaching = true): Bootstrap
+    public static function loadExtTables(bool $allowCaching = true)
     {
         ExtensionManagementUtility::loadExtTables($allowCaching);
-        $this->runExtTablesPostProcessingHooks();
-        return $this;
+        static::runExtTablesPostProcessingHooks();
+        return static::$instance;
     }
 
     /**
@@ -599,7 +599,7 @@ class Bootstrap
      *
      * @throws \UnexpectedValueException
      */
-    protected function runExtTablesPostProcessingHooks()
+    protected static function runExtTablesPostProcessingHooks()
     {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] ?? [] as $className) {
             /** @var $hookObject \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface */
@@ -618,10 +618,10 @@ class Bootstrap
      * Initialize the Routing for the TYPO3 Backend
      * Loads all routes registered inside all packages and stores them inside the Router
      *
-     * @return Bootstrap
+     * @return Bootstrap|null
      * @internal This is not a public API method, do not use in own extensions
      */
-    public function initializeBackendRouter()
+    public static function initializeBackendRouter()
     {
         // See if the Routes.php from all active packages have been built together already
         $cacheIdentifier = 'BackendRoutesFromPackages_' . sha1((TYPO3_version . PATH_site . 'BackendRoutesFromPackages'));
@@ -669,17 +669,17 @@ class Bootstrap
             $route = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\Route::class, $path, $options);
             $router->addRoute($name, $route);
         }
-        return $this;
+        return static::$instance;
     }
 
     /**
      * Initialize backend user object in globals
      *
      * @param string $className usually \TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class but can be used for CLI
-     * @return Bootstrap
+     * @return Bootstrap|null
      * @internal This is not a public API method, do not use in own extensions
      */
-    public function initializeBackendUser($className = \TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class)
+    public static function initializeBackendUser($className = \TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class)
     {
         /** @var $backendUser \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */
         $backendUser = GeneralUtility::makeInstance($className);
@@ -687,7 +687,7 @@ class Bootstrap
         // might trigger code which relies on it. See: #45625
         $GLOBALS['BE_USER'] = $backendUser;
         $backendUser->start();
-        return $this;
+        return static::$instance;
     }
 
     /**
@@ -695,25 +695,25 @@ class Bootstrap
      *
      * @internal This is not a public API method, do not use in own extensions
      * @param bool $proceedIfNoUserIsLoggedIn if set to TRUE, no forced redirect to the login page will be done
-     * @return \TYPO3\CMS\Core\Core\Bootstrap
+     * @return Bootstrap|null
      */
-    public function initializeBackendAuthentication($proceedIfNoUserIsLoggedIn = false)
+    public static function initializeBackendAuthentication($proceedIfNoUserIsLoggedIn = false)
     {
         $GLOBALS['BE_USER']->backendCheckLogin($proceedIfNoUserIsLoggedIn);
-        return $this;
+        return static::$instance;
     }
 
     /**
      * Initialize language object
      *
-     * @return Bootstrap
+     * @return Bootstrap|null
      * @internal This is not a public API method, do not use in own extensions
      */
-    public function initializeLanguageObject()
+    public static function initializeLanguageObject()
     {
         /** @var $GLOBALS['LANG'] \TYPO3\CMS\Core\Localization\LanguageService */
         $GLOBALS['LANG'] = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class);
         $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
-        return $this;
+        return static::$instance;
     }
 }
diff --git a/typo3/sysext/core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php b/typo3/sysext/core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php
index f0f1937614f4..bcbb03e48760 100644
--- a/typo3/sysext/core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php
+++ b/typo3/sysext/core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php
@@ -87,7 +87,7 @@ abstract class AbstractDataHandlerActionTestCase extends FunctionalTestCase
         $this->backendUser->workspace = 0;
 
         $this->actionService = $this->getActionService();
-        Bootstrap::getInstance()->initializeLanguageObject();
+        Bootstrap::initializeLanguageObject();
     }
 
     protected function tearDown()
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php b/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
index e03244407ebe..a11455e939c1 100644
--- a/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
+++ b/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
@@ -421,9 +421,8 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface
     {
         $this->reloadOpcache();
         \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtLocalconf(false);
-        \TYPO3\CMS\Core\Core\Bootstrap::getInstance()
-            ->loadBaseTca(false)
-            ->loadExtTables(false);
+        \TYPO3\CMS\Core\Core\Bootstrap::loadBaseTca(false);
+        \TYPO3\CMS\Core\Core\Bootstrap::loadExtTables(false);
     }
 
     /**
diff --git a/typo3/sysext/frontend/Classes/Middleware/BackendUserAuthenticator.php b/typo3/sysext/frontend/Classes/Middleware/BackendUserAuthenticator.php
index a415d65c1f40..9f64161c1871 100644
--- a/typo3/sysext/frontend/Classes/Middleware/BackendUserAuthenticator.php
+++ b/typo3/sysext/frontend/Classes/Middleware/BackendUserAuthenticator.php
@@ -80,10 +80,9 @@ class BackendUserAuthenticator implements MiddlewareInterface
         // like $GLOBALS['LANG'] for labels in the language of the BE User, the router, and ext_tables.php for all modules
         // So things like Frontend Editing and Admin Panel can use this for generating links to the TYPO3 Backend.
         if ($GLOBALS['BE_USER'] instanceof FrontendBackendUserAuthentication) {
-            Bootstrap::getInstance()
-                ->initializeLanguageObject()
-                ->initializeBackendRouter()
-                ->loadExtTables();
+            Bootstrap::initializeLanguageObject();
+            Bootstrap::initializeBackendRouter();
+            Bootstrap::loadExtTables();
             // Initialize admin panel since simulation settings are required here
             $GLOBALS['BE_USER']->initializeAdminPanel();
         }
diff --git a/typo3/sysext/impexp/Classes/Command/ImportCommand.php b/typo3/sysext/impexp/Classes/Command/ImportCommand.php
index 1e3868820a50..1e8cea44c113 100644
--- a/typo3/sysext/impexp/Classes/Command/ImportCommand.php
+++ b/typo3/sysext/impexp/Classes/Command/ImportCommand.php
@@ -80,7 +80,7 @@ class ImportCommand extends Command
         $io = new SymfonyStyle($input, $output);
 
         // Ensure the _cli_ user is authenticated
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $pageId = (int)$input->getArgument('pageId');
 
diff --git a/typo3/sysext/impexp/Tests/Functional/AbstractImportExportTestCase.php b/typo3/sysext/impexp/Tests/Functional/AbstractImportExportTestCase.php
index 3653ed59b3d1..a2537190531d 100644
--- a/typo3/sysext/impexp/Tests/Functional/AbstractImportExportTestCase.php
+++ b/typo3/sysext/impexp/Tests/Functional/AbstractImportExportTestCase.php
@@ -66,7 +66,7 @@ abstract class AbstractImportExportTestCase extends FunctionalTestCase
 
         $backendUser = $this->setUpBackendUserFromFixture(1);
         $backendUser->workspace = 0;
-        Bootstrap::getInstance()->initializeLanguageObject();
+        Bootstrap::initializeLanguageObject();
     }
 
     /**
diff --git a/typo3/sysext/install/Classes/Controller/AbstractController.php b/typo3/sysext/install/Classes/Controller/AbstractController.php
index 16fc2bfce7da..9821c1b0364f 100644
--- a/typo3/sysext/install/Classes/Controller/AbstractController.php
+++ b/typo3/sysext/install/Classes/Controller/AbstractController.php
@@ -56,10 +56,9 @@ class AbstractController
      */
     protected function loadExtLocalconfDatabaseAndExtTables()
     {
-        \TYPO3\CMS\Core\Core\Bootstrap::getInstance()
-            ->loadTypo3LoadedExtAndExtLocalconf(false)
-            ->unsetReservedGlobalVariables()
-            ->loadBaseTca(false)
-            ->loadExtTables(false);
+        \TYPO3\CMS\Core\Core\Bootstrap::loadTypo3LoadedExtAndExtLocalconf(false);
+        \TYPO3\CMS\Core\Core\Bootstrap::unsetReservedGlobalVariables();
+        \TYPO3\CMS\Core\Core\Bootstrap::loadBaseTca(false);
+        \TYPO3\CMS\Core\Core\Bootstrap::loadExtTables(false);
     }
 }
diff --git a/typo3/sysext/install/Classes/Controller/InstallerController.php b/typo3/sysext/install/Classes/Controller/InstallerController.php
index d7b5898c15b6..323aeea2bc18 100644
--- a/typo3/sysext/install/Classes/Controller/InstallerController.php
+++ b/typo3/sysext/install/Classes/Controller/InstallerController.php
@@ -1115,10 +1115,9 @@ For each website you need a TypoScript template on the main page of your website
      */
     protected function loadExtLocalconfDatabaseAndExtTables()
     {
-        \TYPO3\CMS\Core\Core\Bootstrap::getInstance()
-            ->loadTypo3LoadedExtAndExtLocalconf(false)
-            ->unsetReservedGlobalVariables()
-            ->loadBaseTca(false)
-            ->loadExtTables(false);
+        \TYPO3\CMS\Core\Core\Bootstrap::loadTypo3LoadedExtAndExtLocalconf(false);
+        \TYPO3\CMS\Core\Core\Bootstrap::unsetReservedGlobalVariables();
+        \TYPO3\CMS\Core\Core\Bootstrap::loadBaseTca(false);
+        \TYPO3\CMS\Core\Core\Bootstrap::loadExtTables(false);
     }
 }
diff --git a/typo3/sysext/install/Classes/Controller/SettingsController.php b/typo3/sysext/install/Classes/Controller/SettingsController.php
index 67157094a873..e92fae6bf5d0 100644
--- a/typo3/sysext/install/Classes/Controller/SettingsController.php
+++ b/typo3/sysext/install/Classes/Controller/SettingsController.php
@@ -323,7 +323,7 @@ class SettingsController extends AbstractController
     public function extensionConfigurationGetContentAction(ServerRequestInterface $request): ResponseInterface
     {
         // Extension configuration needs initialized $GLOBALS['LANG']
-        Bootstrap::getInstance()->initializeLanguageObject();
+        Bootstrap::initializeLanguageObject();
         $extensionConfigurationService = new ExtensionConfigurationService();
         $extensionsWithConfigurations = [];
         $activePackages = GeneralUtility::makeInstance(PackageManager::class)->getActivePackages();
diff --git a/typo3/sysext/install/Classes/Service/ClearCacheService.php b/typo3/sysext/install/Classes/Service/ClearCacheService.php
index b48ca133865e..1235ea2f2aaf 100644
--- a/typo3/sysext/install/Classes/Service/ClearCacheService.php
+++ b/typo3/sysext/install/Classes/Service/ClearCacheService.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Service;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -41,7 +42,7 @@ class ClearCacheService
         // Delete typo3temp/Cache
         GeneralUtility::flushDirectory(PATH_site . 'typo3temp/var/Cache', true, true);
 
-        $bootstrap = \TYPO3\CMS\Core\Core\Bootstrap::getInstance();
+        $bootstrap = Bootstrap::getInstance();
         $bootstrap
             ->initializeCachingFramework()
             ->initializePackageManagement(\TYPO3\CMS\Core\Package\PackageManager::class);
@@ -69,11 +70,10 @@ class ClearCacheService
         // From this point on, the code may fatal, if some broken extension is loaded.
 
         // Use bootstrap to load all ext_localconf and ext_tables
-        $bootstrap
-            ->loadTypo3LoadedExtAndExtLocalconf(false)
-            ->unsetReservedGlobalVariables()
-            ->loadBaseTca(false)
-            ->loadExtTables(false);
+        Bootstrap::loadTypo3LoadedExtAndExtLocalconf(false);
+        Bootstrap::unsetReservedGlobalVariables();
+        Bootstrap::loadBaseTca(false);
+        Bootstrap::loadExtTables(false);
 
         // The cache manager is already instantiated in the install tool
         // with some hacked settings to disable caching of extbase and fluid.
diff --git a/typo3/sysext/lowlevel/Classes/Command/CleanFlexFormsCommand.php b/typo3/sysext/lowlevel/Classes/Command/CleanFlexFormsCommand.php
index bcda9b54d1f1..fc3f16e3f688 100644
--- a/typo3/sysext/lowlevel/Classes/Command/CleanFlexFormsCommand.php
+++ b/typo3/sysext/lowlevel/Classes/Command/CleanFlexFormsCommand.php
@@ -71,7 +71,7 @@ class CleanFlexFormsCommand extends Command
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         // Make sure the _cli_ user is loaded
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $io = new SymfonyStyle($input, $output);
         $io->title($this->getDescription());
diff --git a/typo3/sysext/lowlevel/Classes/Command/DeletedRecordsCommand.php b/typo3/sysext/lowlevel/Classes/Command/DeletedRecordsCommand.php
index 3d6ddc4ef6a5..99c947e2e3ba 100644
--- a/typo3/sysext/lowlevel/Classes/Command/DeletedRecordsCommand.php
+++ b/typo3/sysext/lowlevel/Classes/Command/DeletedRecordsCommand.php
@@ -71,7 +71,7 @@ class DeletedRecordsCommand extends Command
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         // Make sure the _cli_ user is loaded
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $io = new SymfonyStyle($input, $output);
         $io->title($this->getDescription());
diff --git a/typo3/sysext/lowlevel/Classes/Command/FilesWithMultipleReferencesCommand.php b/typo3/sysext/lowlevel/Classes/Command/FilesWithMultipleReferencesCommand.php
index 0b4fc2b3410d..a0acb386a560 100644
--- a/typo3/sysext/lowlevel/Classes/Command/FilesWithMultipleReferencesCommand.php
+++ b/typo3/sysext/lowlevel/Classes/Command/FilesWithMultipleReferencesCommand.php
@@ -82,7 +82,7 @@ If you want to get more detailed information, use the --verbose option.')
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         // Make sure the _cli_ user is loaded
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $io = new SymfonyStyle($input, $output);
         $io->title($this->getDescription());
diff --git a/typo3/sysext/lowlevel/Classes/Command/LostFilesCommand.php b/typo3/sysext/lowlevel/Classes/Command/LostFilesCommand.php
index ccda74e119a3..5e263d8cd0ee 100644
--- a/typo3/sysext/lowlevel/Classes/Command/LostFilesCommand.php
+++ b/typo3/sysext/lowlevel/Classes/Command/LostFilesCommand.php
@@ -93,7 +93,7 @@ If you want to get more detailed information, use the --verbose option.')
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         // Make sure the _cli_ user is loaded
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $io = new SymfonyStyle($input, $output);
         $io->title($this->getDescription());
diff --git a/typo3/sysext/lowlevel/Classes/Command/MissingFilesCommand.php b/typo3/sysext/lowlevel/Classes/Command/MissingFilesCommand.php
index b6338d826f24..ac6dd2736061 100644
--- a/typo3/sysext/lowlevel/Classes/Command/MissingFilesCommand.php
+++ b/typo3/sysext/lowlevel/Classes/Command/MissingFilesCommand.php
@@ -82,7 +82,7 @@ If you want to get more detailed information, use the --verbose option.')
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         // Make sure the _cli_ user is loaded
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $io = new SymfonyStyle($input, $output);
         $io->title($this->getDescription());
diff --git a/typo3/sysext/lowlevel/Classes/Command/MissingRelationsCommand.php b/typo3/sysext/lowlevel/Classes/Command/MissingRelationsCommand.php
index 59b2ccd39d61..505cc3f4a1e5 100644
--- a/typo3/sysext/lowlevel/Classes/Command/MissingRelationsCommand.php
+++ b/typo3/sysext/lowlevel/Classes/Command/MissingRelationsCommand.php
@@ -97,7 +97,7 @@ If you want to get more detailed information, use the --verbose option.')
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         // Make sure the _cli_ user is loaded
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $io = new SymfonyStyle($input, $output);
         $io->title($this->getDescription());
diff --git a/typo3/sysext/lowlevel/Classes/Command/OrphanRecordsCommand.php b/typo3/sysext/lowlevel/Classes/Command/OrphanRecordsCommand.php
index 07247e8022a8..df8d732829df 100644
--- a/typo3/sysext/lowlevel/Classes/Command/OrphanRecordsCommand.php
+++ b/typo3/sysext/lowlevel/Classes/Command/OrphanRecordsCommand.php
@@ -70,7 +70,7 @@ Manual repair suggestions:
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         // Make sure the _cli_ user is loaded
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $io = new SymfonyStyle($input, $output);
         $io->title($this->getDescription());
diff --git a/typo3/sysext/lowlevel/Classes/Command/RteImagesCommand.php b/typo3/sysext/lowlevel/Classes/Command/RteImagesCommand.php
index ded59ced13ee..365c71632232 100644
--- a/typo3/sysext/lowlevel/Classes/Command/RteImagesCommand.php
+++ b/typo3/sysext/lowlevel/Classes/Command/RteImagesCommand.php
@@ -88,7 +88,7 @@ If you want to get more detailed information, use the --verbose option.')
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         // Make sure the _cli_ user is loaded
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $io = new SymfonyStyle($input, $output);
         $io->title($this->getDescription());
diff --git a/typo3/sysext/recycler/Tests/Functional/Recycle/AbstractRecycleTestCase.php b/typo3/sysext/recycler/Tests/Functional/Recycle/AbstractRecycleTestCase.php
index 99bfb8e59be3..eadb6507d606 100644
--- a/typo3/sysext/recycler/Tests/Functional/Recycle/AbstractRecycleTestCase.php
+++ b/typo3/sysext/recycler/Tests/Functional/Recycle/AbstractRecycleTestCase.php
@@ -41,7 +41,7 @@ abstract class AbstractRecycleTestCase extends \TYPO3\TestingFramework\Core\Func
     {
         parent::setUp();
         $this->importDataSet(__DIR__ . '/../Fixtures/Database/be_groups.xml');
-        \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
+        \TYPO3\CMS\Core\Core\Bootstrap::initializeLanguageObject();
     }
 
     /**
diff --git a/typo3/sysext/scheduler/Classes/Command/SchedulerCommand.php b/typo3/sysext/scheduler/Classes/Command/SchedulerCommand.php
index 7667ebc1a469..917dfed0217a 100644
--- a/typo3/sysext/scheduler/Classes/Command/SchedulerCommand.php
+++ b/typo3/sysext/scheduler/Classes/Command/SchedulerCommand.php
@@ -76,7 +76,7 @@ Call it like this: typo3/sysext/core/bin/typo3 scheduler:run --task=13 -f')
     public function execute(InputInterface $input, OutputInterface $output)
     {
         // Make sure the _cli_ user is loaded
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $this->scheduler = GeneralUtility::makeInstance(Scheduler::class);
 
diff --git a/typo3/sysext/workspaces/Classes/Command/WorkspaceVersionRecordsCommand.php b/typo3/sysext/workspaces/Classes/Command/WorkspaceVersionRecordsCommand.php
index 1f9aa32ec561..aa9f887f4a8a 100644
--- a/typo3/sysext/workspaces/Classes/Command/WorkspaceVersionRecordsCommand.php
+++ b/typo3/sysext/workspaces/Classes/Command/WorkspaceVersionRecordsCommand.php
@@ -104,7 +104,7 @@ class WorkspaceVersionRecordsCommand extends Command
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         // Make sure the _cli_ user is loaded
-        Bootstrap::getInstance()->initializeBackendAuthentication();
+        Bootstrap::initializeBackendAuthentication();
 
         $io = new SymfonyStyle($input, $output);
         $io->title($this->getDescription());
diff --git a/typo3/sysext/workspaces/Tests/Functional/ActionHandler/ActionHandlerTest.php b/typo3/sysext/workspaces/Tests/Functional/ActionHandler/ActionHandlerTest.php
index 28a603a1f188..e7fac63dfec4 100644
--- a/typo3/sysext/workspaces/Tests/Functional/ActionHandler/ActionHandlerTest.php
+++ b/typo3/sysext/workspaces/Tests/Functional/ActionHandler/ActionHandlerTest.php
@@ -33,7 +33,7 @@ class ActionHandlerTest extends \TYPO3\TestingFramework\Core\Functional\Function
     {
         parent::setUp();
         $this->setUpBackendUserFromFixture(1);
-        \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
+        \TYPO3\CMS\Core\Core\Bootstrap::initializeLanguageObject();
     }
 
     /**
diff --git a/typo3/sysext/workspaces/Tests/Functional/Service/WorkspaceServiceTest.php b/typo3/sysext/workspaces/Tests/Functional/Service/WorkspaceServiceTest.php
index 93d5b6b50dad..5e0fb38ce6df 100644
--- a/typo3/sysext/workspaces/Tests/Functional/Service/WorkspaceServiceTest.php
+++ b/typo3/sysext/workspaces/Tests/Functional/Service/WorkspaceServiceTest.php
@@ -35,7 +35,7 @@ class WorkspaceServiceTest extends FunctionalTestCase
     {
         parent::setUp();
         $this->setUpBackendUserFromFixture(1);
-        Bootstrap::getInstance()->initializeLanguageObject();
+        Bootstrap::initializeLanguageObject();
         $this->importDataSet(__DIR__ . '/../Fixtures/sys_workspace.xml');
     }
 
-- 
GitLab