[TASK] Follow-up to TCA refactoring
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Core / Bootstrap.php
index 2c088e9..e20f5b6 100644 (file)
@@ -1,6 +1,32 @@
 <?php
 namespace TYPO3\CMS\Core\Core;
 
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
 require 'SystemEnvironmentBuilder.php';
 
 /**
@@ -15,8 +41,6 @@ require 'SystemEnvironmentBuilder.php';
  * exactly what you are doing!
  *
  * @author Christian Kuhn <lolli@schwarzbu.ch>
- * @package TYPO3
- * @subpackage core
  */
 class Bootstrap {
 
@@ -50,6 +74,7 @@ class Bootstrap {
         * Return 'this' as singleton
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        static public function getInstance() {
                if (is_null(self::$instance)) {
@@ -62,6 +87,7 @@ class Bootstrap {
         * Gets the request's unique ID
         *
         * @return string Unique request ID
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function getRequestId() {
                return $this->requestId;
@@ -72,6 +98,7 @@ class Bootstrap {
         * This does not interfere with "die()" or "echo"+"exit()" messages!
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function startOutputBuffering() {
                ob_start();
@@ -86,6 +113,7 @@ class Bootstrap {
         *
         * @param string $relativePathPart Relative path of the entry script back to document root
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function baseSetup($relativePathPart = '') {
                \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::run($relativePathPart);
@@ -93,10 +121,85 @@ class Bootstrap {
        }
 
        /**
+        * Includes LocalConfiguration.php and sets several
+        * global settings depending on configuration.
+        *
+        * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
+        */
+       public function loadConfigurationAndInitialize() {
+               $this->getInstance()
+                       ->populateLocalConfiguration()
+                       ->registerExtDirectComponents()
+                       ->initializeCachingFramework()
+                       ->registerAutoloader()
+                       ->checkUtf8DatabaseSettingsOrDie()
+                       ->transferDeprecatedCurlSettings()
+                       ->setCacheHashOptions()
+                       ->enforceCorrectProxyAuthScheme()
+                       ->setDefaultTimezone()
+                       ->initializeL10nLocales()
+                       ->configureImageProcessingOptions()
+                       ->convertPageNotFoundHandlingToBoolean()
+                       ->registerGlobalDebugFunctions()
+                       ->registerSwiftMailer()
+                       ->configureExceptionHandling()
+                       ->setMemoryLimit()
+                       ->defineTypo3RequestTypes();
+               return $this;
+       }
+
+       /**
+        * Load TYPO3_LOADED_EXT and ext_localconf
+        *
+        * @param boolean $allowCaching
+        * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
+        */
+       public function loadTypo3LoadedExtAndExtLocalconf($allowCaching = TRUE) {
+               $this->getInstance()
+                       ->populateTypo3LoadedExtGlobal($allowCaching)
+                       ->loadAdditionalConfigurationFromExtensions($allowCaching);
+               return $this;
+       }
+
+       /**
+        * Load TYPO3_LOADED_EXT, recreate class loader registry and load ext_localconf
+        *
+        * @param boolean $allowCaching
+        * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
+        */
+       public function reloadTypo3LoadedExtAndClassLoaderAndExtLocalconf() {
+               $bootstrap = $this->getInstance();
+               $bootstrap->populateTypo3LoadedExtGlobal(FALSE);
+               \TYPO3\CMS\Core\Core\ClassLoader::loadClassLoaderCache();
+               $bootstrap->loadAdditionalConfigurationFromExtensions(FALSE);
+               return $this;
+       }
+
+       /**
+        * Sets up additional configuration applied in all scopes
+        *
+        * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
+        */
+       public function applyAdditionalConfigurationSettings() {
+               $this->getInstance()
+                       ->deprecationLogForOldExtCacheSetting()
+                       ->initializeExceptionHandling()
+                       ->setFinalCachingFrameworkCacheConfiguration()
+                       ->defineLoggingAndExceptionConstants()
+                       ->unsetReservedGlobalVariables();
+               return $this;
+       }
+
+       /**
         * Throws an exception if no browser could be identified
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         * @throws \RuntimeException
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function checkValidBrowserOrDie() {
                // Checks for proper browser
@@ -107,71 +210,53 @@ class Bootstrap {
        }
 
        /**
-        * Register default ExtDirect components
+        * Populate the local configuration.
+        * Merge default TYPO3_CONF_VARS with content of typo3conf/LocalConfiguration.php,
+        * execute typo3conf/AdditionalConfiguration.php, define database related constants.
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function registerExtDirectComponents() {
-               if (TYPO3_MODE === 'BE') {
-                       \TYPO3\CMS\Core\Extension\ExtensionManager::registerExtDirectComponent('TYPO3.Components.PageTree.DataProvider', PATH_t3lib . 'tree/pagetree/extdirect/class.t3lib_tree_pagetree_extdirect_tree.php:TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeDataProvide', 'web', 'user,group');
-                       \TYPO3\CMS\Core\Extension\ExtensionManager::registerExtDirectComponent('TYPO3.Components.PageTree.Commands', PATH_t3lib . 'tree/pagetree/extdirect/class.t3lib_tree_pagetree_extdirect_tree.php:TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeCommands', 'web', 'user,group');
-                       \TYPO3\CMS\Core\Extension\ExtensionManager::registerExtDirectComponent('TYPO3.Components.PageTree.ContextMenuDataProvider', PATH_t3lib . 'contextmenu/pagetree/extdirect/class.t3lib_contextmenu_pagetree_extdirect_contextmenu.php:TYPO3\\CMS\\Backend\\ContextMenu\\Pagetree\\Extdirect\\ContextMenuConfiguration', 'web', 'user,group');
-                       \TYPO3\CMS\Core\Extension\ExtensionManager::registerExtDirectComponent('TYPO3.LiveSearchActions.ExtDirect', PATH_t3lib . 'extjs/dataprovider/class.extdirect_dataprovider_backendlivesearch.php:extDirect_DataProvider_BackendLiveSearch', 'web_list', 'user,group');
-                       \TYPO3\CMS\Core\Extension\ExtensionManager::registerExtDirectComponent('TYPO3.BackendUserSettings.ExtDirect', PATH_t3lib . 'extjs/dataprovider/class.extdirect_dataprovider_beusersettings.php:TYPO3\\CMS\\Backend\\User\\ExtDirect\\BackendUserSettingsDataProvider');
-                       \TYPO3\CMS\Core\Extension\ExtensionManager::registerExtDirectComponent('TYPO3.CSH.ExtDirect', PATH_t3lib . 'extjs/dataprovider/class.extdirect_dataprovider_contexthelp.php:TYPO3\\CMS\\ContextHelp\\ExtDirect\\ContextHelpDataProvider');
-                       \TYPO3\CMS\Core\Extension\ExtensionManager::registerExtDirectComponent('TYPO3.ExtDirectStateProvider.ExtDirect', PATH_t3lib . 'extjs/dataprovider/class.extdirect_dataprovider_state.php:TYPO3\\CMS\\Backend\\InterfaceState\\ExtDirect\\DataProvider');
+       protected function populateLocalConfiguration() {
+               try {
+                       // We need an early instance of the configuration manager.
+                       // Since makeInstance relies on the object configuration, we create it here with new instead
+                       // and register it as singleton instance for later use.
+                       $configuarationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager();
+                       \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager', $configuarationManager);
+                       $configuarationManager->exportConfiguration();
+               } catch (\Exception $e) {
+                       die($e->getMessage());
                }
+               define('TYPO3_db', $GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
+               define('TYPO3_db_username', $GLOBALS['TYPO3_CONF_VARS']['DB']['username']);
+               define('TYPO3_db_password', $GLOBALS['TYPO3_CONF_VARS']['DB']['password']);
+               define('TYPO3_db_host', $GLOBALS['TYPO3_CONF_VARS']['DB']['host']);
+               define('TYPO3_extTableDef_script',
+                       isset($GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript'])
+                       ? $GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript']
+                       : 'extTables.php');
+               unset($GLOBALS['TYPO3_CONF_VARS']['DB']);
+               define('TYPO3_user_agent', 'User-Agent: ' . $GLOBALS['TYPO3_CONF_VARS']['HTTP']['userAgent']);
                return $this;
        }
 
        /**
-        * Populate the local configuration.
-        * Merge default TYPO3_CONF_VARS with content of typo3conf/LocalConfiguration.php,
-        * execute typo3conf/AdditionalConfiguration.php, define database related constants.
+        * Register default ExtDirect components
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function populateLocalConfiguration() {
-               if (@is_file((PATH_site . \TYPO3\CMS\Core\Configuration\ConfigurationManager::LOCAL_CONFIGURATION_FILE))) {
-                       $localConfiguration = \TYPO3\CMS\Core\Configuration\ConfigurationManager::getLocalConfiguration();
-                       if (is_array($localConfiguration)) {
-                               $GLOBALS['TYPO3_CONF_VARS'] = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($GLOBALS['TYPO3_CONF_VARS'], $localConfiguration);
-                       } else {
-                               die('LocalConfiguration invalid.');
-                       }
-                       if (@is_file((PATH_site . \TYPO3\CMS\Core\Configuration\ConfigurationManager::ADDITIONAL_CONFIGURATION_FILE))) {
-                               require PATH_site . \TYPO3\CMS\Core\Configuration\ConfigurationManager::ADDITIONAL_CONFIGURATION_FILE;
-                       }
-                       define('TYPO3_db', $GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
-                       define('TYPO3_db_username', $GLOBALS['TYPO3_CONF_VARS']['DB']['username']);
-                       define('TYPO3_db_password', $GLOBALS['TYPO3_CONF_VARS']['DB']['password']);
-                       define('TYPO3_db_host', $GLOBALS['TYPO3_CONF_VARS']['DB']['host']);
-                       define('TYPO3_extTableDef_script', $GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript']);
-                       unset($GLOBALS['TYPO3_CONF_VARS']['DB']);
-               } elseif (@is_file((PATH_site . \TYPO3\CMS\Core\Configuration\ConfigurationManager::LOCALCONF_FILE))) {
-                       // Legacy localconf.php handling
-                       // @deprecated: Can be removed if old localconf.php is not supported anymore
-                       global $TYPO3_CONF_VARS, $typo_db, $typo_db_username, $typo_db_password, $typo_db_host, $typo_db_extTableDef_script;
-                       require PATH_site . \TYPO3\CMS\Core\Configuration\ConfigurationManager::LOCALCONF_FILE;
-                       // If the localconf.php was not upgraded to LocalConfiguration.php, the default extListArray
-                       // from t3lib/stddb/DefaultConfiguration.php is still set. In this case we just unset
-                       // this key here, so t3lib_extMgm::getLoadedExtensionListArray() falls back to use extList string
-                       // @deprecated: This case can be removed later if localconf.php is not supported anymore
-                       unset($TYPO3_CONF_VARS['EXT']['extListArray']);
-                       define('TYPO3_db', $typo_db);
-                       define('TYPO3_db_username', $typo_db_username);
-                       define('TYPO3_db_password', $typo_db_password);
-                       define('TYPO3_db_host', $typo_db_host);
-                       define('TYPO3_extTableDef_script', $typo_db_extTableDef_script);
-                       unset($GLOBALS['typo_db']);
-                       unset($GLOBALS['typo_db_username']);
-                       unset($GLOBALS['typo_db_password']);
-                       unset($GLOBALS['typo_db_host']);
-                       unset($GLOBALS['typo_db_extTableDef_script']);
-               } else {
-                       die(\TYPO3\CMS\Core\Configuration\ConfigurationManager::LOCALCONF_FILE . ' not found!');
+       protected function registerExtDirectComponents() {
+               if (TYPO3_MODE === 'BE') {
+                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.DataProvider', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeDataProvider', 'web', 'user,group');
+                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.Commands', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeCommands', 'web', 'user,group');
+                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.ContextMenuDataProvider', 'TYPO3\\CMS\\Backend\\ContextMenu\\Pagetree\\Extdirect\\ContextMenuConfiguration', 'web', 'user,group');
+                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.LiveSearchActions.ExtDirect', 'TYPO3\\CMS\\Backend\\Search\\LiveSearch\\ExtDirect\\LiveSearchDataProvider', 'web_list', 'user,group');
+                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.BackendUserSettings.ExtDirect', 'TYPO3\\CMS\\Backend\\User\\ExtDirect\\BackendUserSettingsDataProvider');
+                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.CSH.ExtDirect', 'TYPO3\\CMS\\ContextHelp\\ExtDirect\\ContextHelpDataProvider');
+                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.ExtDirectStateProvider.ExtDirect', 'TYPO3\\CMS\\Backend\\InterfaceState\\ExtDirect\\DataProvider');
+                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.DragAndDrop.CommandController',
+                               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('backend') . 'Classes/View/PageLayout/Extdirect/ExtdirectPageCommands.php:TYPO3\\CMS\\Backend\\View\\PageLayout\\ExtDirect\\ExtdirectPageCommands', 'web', 'user,group');
                }
-               define('TYPO3_user_agent', 'User-Agent: ' . $GLOBALS['TYPO3_CONF_VARS']['HTTP']['userAgent']);
                return $this;
        }
 
@@ -179,6 +264,7 @@ class Bootstrap {
         * Redirect to install tool if database host and database are not defined
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function redirectToInstallToolIfDatabaseCredentialsAreMissing() {
                if (!TYPO3_db_host && !TYPO3_db) {
@@ -192,7 +278,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function initializeCachingFramework() {
+       protected function initializeCachingFramework() {
                \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework();
                return $this;
        }
@@ -202,7 +288,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function registerAutoloader() {
+       protected function registerAutoloader() {
                if (PHP_VERSION_ID < 50307) {
                        \TYPO3\CMS\Core\Compatibility\CompatbilityClassLoaderPhpBelow50307::registerAutoloader();
                } else {
@@ -222,7 +308,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function checkUtf8DatabaseSettingsOrDie() {
+       protected function checkUtf8DatabaseSettingsOrDie() {
                // Check if [BE][forceCharset] has been set in localconf.php
                if (isset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'])) {
                        // die() unless we're already on UTF-8
@@ -247,7 +333,7 @@ class Bootstrap {
         * @TODO : This code segment must still be finished
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function transferDeprecatedCurlSettings() {
+       protected function transferDeprecatedCurlSettings() {
                if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'])) {
                        $proxyParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'], 2);
                        $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = $proxyParts[0];
@@ -266,7 +352,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function setCacheHashOptions() {
+       protected function setCacheHashOptions() {
                $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] = array(
                        'cachedParametersWhiteList' => \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashOnlyForParameters'], TRUE),
                        'excludedParameters' => \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'], TRUE),
@@ -286,7 +372,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function enforceCorrectProxyAuthScheme() {
+       protected function enforceCorrectProxyAuthScheme() {
                $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] === 'digest' ?: ($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] = 'basic');
                return $this;
        }
@@ -296,7 +382,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function setDefaultTimezone() {
+       protected function setDefaultTimezone() {
                $timeZone = $GLOBALS['TYPO3_CONF_VARS']['SYS']['phpTimeZone'];
                if (empty($timeZone)) {
                        // Time zone from the server environment (TZ env or OS query)
@@ -317,7 +403,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function initializeL10nLocales() {
+       protected function initializeL10nLocales() {
                \TYPO3\CMS\Core\Localization\Locales::initialize();
                return $this;
        }
@@ -328,7 +414,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function configureImageProcessingOptions() {
+       protected function configureImageProcessingOptions() {
                if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['image_processing']) {
                        $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] = 0;
                        $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'] = 0;
@@ -363,7 +449,7 @@ class Bootstrap {
         * @TODO : Remove, if the Install Tool handles such data types correctly
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function convertPageNotFoundHandlingToBoolean() {
+       protected function convertPageNotFoundHandlingToBoolean() {
                if (!strcasecmp($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'], 'TRUE')) {
                        $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = TRUE;
                }
@@ -378,7 +464,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function registerGlobalDebugFunctions() {
+       protected function registerGlobalDebugFunctions() {
                require_once('GlobalDebugFunctions.php');
                return $this;
        }
@@ -388,7 +474,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function registerSwiftMailer() {
+       protected function registerSwiftMailer() {
                $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'][] = 'TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter';
                return $this;
        }
@@ -398,7 +484,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function configureExceptionHandling() {
+       protected function configureExceptionHandling() {
                $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
                $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'];
                // Turn error logging on/off.
@@ -432,7 +518,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function setMemoryLimit() {
+       protected function setMemoryLimit() {
                if (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) > 16) {
                        @ini_set('memory_limit', (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) . 'm'));
                }
@@ -445,7 +531,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function defineTypo3RequestTypes() {
+       protected function defineTypo3RequestTypes() {
                define('TYPO3_REQUESTTYPE_FE', 1);
                define('TYPO3_REQUESTTYPE_BE', 2);
                define('TYPO3_REQUESTTYPE_CLI', 4);
@@ -462,8 +548,8 @@ class Bootstrap {
         * @param boolean $allowCaching
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function populateTypo3LoadedExtGlobal($allowCaching = TRUE) {
-               $GLOBALS['TYPO3_LOADED_EXT'] = \TYPO3\CMS\Core\Extension\ExtensionManager::loadTypo3LoadedExtensionInformation($allowCaching);
+       protected function populateTypo3LoadedExtGlobal($allowCaching = TRUE) {
+               $GLOBALS['TYPO3_LOADED_EXT'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadTypo3LoadedExtensionInformation($allowCaching);
                return $this;
        }
 
@@ -476,8 +562,8 @@ class Bootstrap {
         * @param boolean $allowCaching
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function loadAdditionalConfigurationFromExtensions($allowCaching = TRUE) {
-               \TYPO3\CMS\Core\Extension\ExtensionManager::loadExtLocalconf($allowCaching);
+       protected function loadAdditionalConfigurationFromExtensions($allowCaching = TRUE) {
+               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtLocalconf($allowCaching);
                return $this;
        }
 
@@ -487,7 +573,7 @@ class Bootstrap {
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         * @deprecated since 6.0, the check will be removed two version later.
         */
-       public function deprecationLogForOldExtCacheSetting() {
+       protected function deprecationLogForOldExtCacheSetting() {
                if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && $GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] !== -1) {
                        \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('Setting $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'extCache\'] is unused and can be removed from localconf.php');
                }
@@ -499,7 +585,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function initializeExceptionHandling() {
+       protected function initializeExceptionHandling() {
                if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] !== '') {
                        if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'] !== '') {
                                // Register an error handler for the given errorHandlerErrors
@@ -515,22 +601,12 @@ class Bootstrap {
        }
 
        /**
-        * Load some additional classes that are encapsulated in extensions
-        *
-        * @return \TYPO3\CMS\Core\Core\Bootstrap
-        */
-       public function requireAdditionalExtensionFiles() {
-               require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('lang') . 'lang.php';
-               return $this;
-       }
-
-       /**
         * Extensions may register new caches, so we set the
         * global cache array to the manager again at this point
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function setFinalCachingFrameworkCacheConfiguration() {
+       protected function setFinalCachingFrameworkCacheConfiguration() {
                $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
                return $this;
        }
@@ -540,7 +616,7 @@ class Bootstrap {
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function defineLoggingAndExceptionConstants() {
+       protected function defineLoggingAndExceptionConstants() {
                define('TYPO3_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']);
                define('TYPO3_ERROR_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG']);
                define('TYPO3_EXCEPTION_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG']);
@@ -549,11 +625,11 @@ class Bootstrap {
 
        /**
         * Unsetting reserved global variables:
-        * Those which are/can be set in "stddb/tables.php" files:
+        * Those are set in "ext:core/ext_tables.php" file:
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         */
-       public function unsetReservedGlobalVariables() {
+       protected function unsetReservedGlobalVariables() {
                unset($GLOBALS['PAGES_TYPES']);
                unset($GLOBALS['TCA']);
                unset($GLOBALS['TBE_MODULES']);
@@ -574,11 +650,12 @@ class Bootstrap {
        /**
         * Initialize t3lib_db in $GLOBALS and connect if requested
         *
-        * @param boolean $connect Whether or not the db should be connected already
+        * @param boolean $connect Whether db should be connected
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function initializeTypo3DbGlobal($connect = TRUE) {
-               /** @var TYPO3_DB t3lib_db */
+               /** @var TYPO3_DB TYPO3\CMS\Core\Database\DatabaseConnection */
                $GLOBALS['TYPO3_DB'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
                $GLOBALS['TYPO3_DB']->debugOutput = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'];
                if ($connect) {
@@ -593,6 +670,7 @@ class Bootstrap {
         *
         * @throws \RuntimeException
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function checkLockedBackendAndRedirectOrDie() {
                if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
@@ -619,6 +697,7 @@ class Bootstrap {
         * if the client is not allowed to access the backend
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function checkBackendIpOrDie() {
                if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
@@ -639,6 +718,7 @@ class Bootstrap {
         * to https version of the backend if needed
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function checkSslBackendAndRedirectIfNeeded() {
                if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'])) {
@@ -677,6 +757,7 @@ class Bootstrap {
         * Establish connection to the database
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function establishDatabaseConnection() {
                $GLOBALS['TYPO3_DB']->connectDB();
@@ -684,6 +765,35 @@ class Bootstrap {
        }
 
        /**
+        * Load TCA for frontend
+        *
+        * This method is *only* executed in frontend scope. The idea is to execute the
+        * whole TCA and ext_tables (which manipulate TCA) on first frontend access,
+        * and then cache the full TCA on disk to be used for the next run again.
+        *
+        * This way, ext_tables.php ist not executed every time, but $GLOBALS['TCA']
+        * is still always there.
+        *
+        * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
+        */
+       public function loadCachedTca() {
+               $cacheIdentifier = 'tca_fe_' . sha1((TYPO3_version . PATH_site . 'tca_fe'));
+               /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
+               $codeCache = $GLOBALS['typo3CacheManager']->getCache('cache_core');
+               if ($codeCache->has($cacheIdentifier)) {
+                       $codeCache->requireOnce($cacheIdentifier);
+               } else {
+                       $this->loadExtensionTables(TRUE);
+                       $phpCodeToCache = '$GLOBALS[\'TCA\'] = ';
+                       $phpCodeToCache .= \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($GLOBALS['TCA']);
+                       $phpCodeToCache .= ';';
+                       $codeCache->set($cacheIdentifier, $phpCodeToCache);
+               }
+               return $this;
+       }
+
+       /**
         * Load ext_tables and friends.
         *
         * This will mainly set up $TCA and several other global arrays
@@ -691,41 +801,51 @@ class Bootstrap {
         * Executes ext_tables.php files of loaded extensions or the
         * according cache file if exists.
         *
+        * @param boolean $allowCaching True, if reading compiled ext_tables file from cache is allowed
+        * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
+        */
+       public function loadExtensionTables($allowCaching = TRUE) {
+               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadBaseTca($allowCaching);
+               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtTables($allowCaching);
+               $this->executeExtTablesAdditionalFile();
+               $this->runExtTablesPostProcessingHooks();
+               return $this;
+       }
+
+       /**
+        * Execute TYPO3_extTableDef_script if defined and exists
+        *
         * Note: For backwards compatibility some global variables are
         * explicitly set as global to be used without $GLOBALS[] in
-        * ext_tables.php. It is discouraged to access variables like
-        * $TBE_MODULES directly in ext_tables.php, but we can not prohibit
+        * the extension table script. It is discouraged to access variables like
+        * $TBE_MODULES directly, but we can not prohibit
         * this without heavily breaking backwards compatibility.
         *
         * @TODO : We could write a scheduler / reports module or an update checker
         * @TODO : It should be defined, which global arrays are ok to be manipulated
-        * @param boolean $allowCaching True, if reading compiled ext_tables file from cache is allowed
-        * @return \TYPO3\CMS\Core\Core\Bootstrap
+        *
+        * @return void
         */
-       public function loadExtensionTables($allowCaching = TRUE) {
+       protected function executeExtTablesAdditionalFile() {
                // It is discouraged to use those global variables directly, but we
                // can not prohibit this without breaking backwards compatibility
                global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
                global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
                global $PAGES_TYPES, $TBE_STYLES, $FILEICONS;
                global $_EXTKEY;
-               // Include standard tables.php file
-               require PATH_t3lib . 'stddb/tables.php';
-               \TYPO3\CMS\Core\Extension\ExtensionManager::loadExtTables($allowCaching);
-               // Load additional ext tables script if registered
-               if (TYPO3_extTableDef_script) {
-                       include PATH_typo3conf . TYPO3_extTableDef_script;
-               }
-               // Run post hook for additional manipulation
-               $this->runExtTablesPostProcessingHooks();
-               return $this;
+               // Load additional ext tables script if the file exists
+               $extTablesFile = PATH_typo3conf . TYPO3_extTableDef_script;
+               if (file_exists($extTablesFile)) {
+                       include $extTablesFile;
+               }
        }
 
        /**
         * Check for registered ext tables hooks and run them
         *
         * @throws \UnexpectedValueException
-        * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @return void
         */
        protected function runExtTablesPostProcessingHooks() {
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
@@ -738,13 +858,13 @@ class Bootstrap {
                                $hookObject->processData();
                        }
                }
-               return $this;
        }
 
        /**
         * Initialize sprite manager
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function initializeSpriteManager() {
                \TYPO3\CMS\Backend\Sprite\SpriteManager::initialize();
@@ -755,6 +875,7 @@ class Bootstrap {
         * Initialize backend user object in globals
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function initializeBackendUser() {
                /** @var $backendUser \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */
@@ -766,10 +887,12 @@ class Bootstrap {
                if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
                        $backendUser->dontSetCookie = TRUE;
                }
+               // The global must be available very early, because methods below
+               // might triger code which relies on it. See: #45625
+               $GLOBALS['BE_USER'] = $backendUser;
                $backendUser->start();
                $backendUser->checkCLIuser();
                $backendUser->backendCheckLogin();
-               $GLOBALS['BE_USER'] = $backendUser;
                return $this;
        }
 
@@ -777,6 +900,7 @@ class Bootstrap {
         * Initialize backend user mount points
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function initializeBackendUserMounts() {
                // Includes deleted mount pages as well! @TODO: Figure out why ...
@@ -789,6 +913,7 @@ class Bootstrap {
         * Initialize language object
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function initializeLanguageObject() {
                /** @var $GLOBALS['LANG'] \TYPO3\CMS\Lang\LanguageService */
@@ -801,6 +926,7 @@ class Bootstrap {
         * Throw away all output that may have happened during bootstrapping by weird extensions
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function endOutputBufferingAndCleanPreviousOutput() {
                ob_clean();
@@ -811,6 +937,7 @@ class Bootstrap {
         * Initialize output compression if configured
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function initializeOutputCompression() {
                if (extension_loaded('zlib') && $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']) {
@@ -826,6 +953,7 @@ class Bootstrap {
         * Initialize module menu object
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function initializeModuleMenuObject() {
                /** @var $moduleMenuUtility Typo3_BackendModule_Utility */
@@ -840,6 +968,7 @@ class Bootstrap {
         * shut down of the system.
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function shutdown() {
                if (PHP_VERSION_ID < 50307) {
@@ -855,6 +984,7 @@ class Bootstrap {
         * work with.
         *
         * @return \TYPO3\CMS\Core\Core\Bootstrap
+        * @internal This is not a public API method, do not use in own extensions
         */
        public function initializeBackendTemplate() {
                $GLOBALS['TBE_TEMPLATE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
@@ -864,4 +994,4 @@ class Bootstrap {
 }
 
 
-?>
\ No newline at end of file
+?>