[BUGFIX] Activate runtimeActivatedPackages without cache clearing
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Core / Bootstrap.php
1 <?php
2 namespace TYPO3\CMS\Core\Core;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility;
18
19 /**
20 * This class encapsulates bootstrap related methods.
21 * It is required directly as the very first thing in entry scripts and
22 * used to define all base things like constants and pathes and so on.
23 *
24 * Most methods in this class have dependencies to each other. They can
25 * not be called in arbitrary order. The methods are ordered top down, so
26 * a method at the beginning has lower dependencies than a method further
27 * down. Do not fiddle with the load order in own scripts except you know
28 * exactly what you are doing!
29 *
30 * @author Christian Kuhn <lolli@schwarzbu.ch>
31 */
32 class Bootstrap {
33
34 /**
35 * @var \TYPO3\CMS\Core\Core\Bootstrap
36 */
37 static protected $instance = NULL;
38
39 /**
40 * Unique Request ID
41 *
42 * @var string
43 */
44 protected $requestId;
45
46 /**
47 * The application context
48 *
49 * @var \TYPO3\CMS\Core\Core\ApplicationContext
50 */
51 protected $applicationContext;
52
53 /**
54 * @var array List of early instances
55 */
56 protected $earlyInstances = array();
57
58 /**
59 * @var string Path to install tool
60 */
61 protected $installToolPath;
62
63 /**
64 * @var string The currently active exception handling class. It is set after LocalConfiguration is included and might be changed after ex_localconf.php are loaded.
65 */
66 protected $activeExceptionHandlerClassName;
67
68 /**
69 * @var string The currently active error handling class. It is set after LocalConfiguration is included and might be changed after ex_localconf.php are loaded.
70 */
71 protected $activeErrorHandlerClassName;
72
73 /**
74 * Disable direct creation of this object.
75 * Set unique requestId and the application context
76 *
77 * @var string Application context
78 */
79 protected function __construct($applicationContext) {
80 $this->requestId = substr(md5(uniqid('', TRUE)), 0, 13);
81 $this->applicationContext = new ApplicationContext($applicationContext);
82 }
83
84 /**
85 * Disable direct cloning of this object.
86 */
87 protected function __clone() {
88
89 }
90
91 /**
92 * Return 'this' as singleton
93 *
94 * @return Bootstrap
95 * @internal This is not a public API method, do not use in own extensions
96 */
97 static public function getInstance() {
98 if (is_null(static::$instance)) {
99 require_once(__DIR__ . '/../Exception.php');
100 require_once(__DIR__ . '/ApplicationContext.php');
101 $applicationContext = getenv('TYPO3_CONTEXT') ?: (getenv('REDIRECT_TYPO3_CONTEXT') ?: 'Production');
102 self::$instance = new static($applicationContext);
103 // Establish an alias for Flow/Package interoperability
104 class_alias(get_class(static::$instance), 'TYPO3\\Flow\\Core\\Bootstrap');
105 }
106 return static::$instance;
107 }
108
109 /**
110 * Gets the request's unique ID
111 *
112 * @return string Unique request ID
113 * @internal This is not a public API method, do not use in own extensions
114 */
115 public function getRequestId() {
116 return $this->requestId;
117 }
118
119 /**
120 * Returns the application context this bootstrap was started in.
121 *
122 * @return \TYPO3\CMS\Core\Core\ApplicationContext The application context encapsulated in an object
123 * @internal This is not a public API method, do not use in own extensions.
124 * Use \TYPO3\CMS\Core\Utility\GeneralUtility::getApplicationContext() instead
125 */
126 public function getApplicationContext() {
127 return $this->applicationContext;
128 }
129
130 /**
131 * Prevent any unwanted output that may corrupt AJAX/compression.
132 * This does not interfere with "die()" or "echo"+"exit()" messages!
133 *
134 * @return Bootstrap
135 * @internal This is not a public API method, do not use in own extensions
136 */
137 public function startOutputBuffering() {
138 ob_start();
139 return $this;
140 }
141
142 /**
143 * Run the base setup that checks server environment, determines pathes,
144 * populates base files and sets common configuration.
145 *
146 * Script execution will be aborted if something fails here.
147 *
148 * @param string $relativePathPart Relative path of entry script back to document root
149 * @return Bootstrap
150 * @internal This is not a public API method, do not use in own extensions
151 */
152 public function baseSetup($relativePathPart = '') {
153 $composerClassLoader = $this->initializeComposerClassLoader();
154 $this->setEarlyInstance('Composer\\Autoload\\ClassLoader', $composerClassLoader);
155 SystemEnvironmentBuilder::run($relativePathPart);
156 Utility\GeneralUtility::presetApplicationContext($this->applicationContext);
157 return $this;
158 }
159
160 /**
161 * @return \Composer\Autoload\ClassLoader
162 */
163 protected function initializeComposerClassLoader() {
164 $respectComposerPackagesForClassLoading = getenv('TYPO3_COMPOSER_AUTOLOAD') ?: (getenv('REDIRECT_TYPO3_COMPOSER_AUTOLOAD') ?: NULL);
165 $possiblePaths = array();
166 if (!empty($respectComposerPackagesForClassLoading)) {
167 $possiblePaths['distribution'] = __DIR__ . '/../../../../../../Packages/Libraries/autoload.php';
168 }
169 $possiblePaths['fallback'] = __DIR__ . '/../../../../contrib/vendor/autoload.php';
170 foreach ($possiblePaths as $possiblePath) {
171 if (file_exists($possiblePath)) {
172 return include $possiblePath;
173 }
174 }
175 throw new \LogicException('No class loading information found for TYPO3 CMS. Please make sure you installed TYPO3 with composer or the typo3/contrib/vendor folder is present.', 1425153762);
176 }
177
178 /**
179 * Redirect to install tool if LocalConfiguration.php is missing.
180 *
181 * @param string $pathUpToDocumentRoot Can contain '../' if called from a sub directory
182 * @return Bootstrap
183 * @internal This is not a public API method, do not use in own extensions
184 */
185 public function redirectToInstallerIfEssentialConfigurationDoesNotExist($pathUpToDocumentRoot = '') {
186 $configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager;
187 $this->setEarlyInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager', $configurationManager);
188 if (!file_exists($configurationManager->getLocalConfigurationFileLocation()) || !file_exists(PATH_typo3conf . 'PackageStates.php')) {
189 define('TYPO3_enterInstallScript', '1');
190 $this->defineTypo3RequestTypes();
191 require_once __DIR__ . '/../Utility/HttpUtility.php';
192 Utility\HttpUtility::redirect($pathUpToDocumentRoot . 'typo3/sysext/install/Start/Install.php');
193 }
194 return $this;
195 }
196
197 /**
198 * Registers the instance of the specified object for an early boot stage.
199 * On finalizing the Object Manager initialization, all those instances will
200 * be transferred to the Object Manager's registry.
201 *
202 * @param string $objectName Object name, as later used by the Object Manager
203 * @param object $instance The instance to register
204 * @return void
205 */
206 public function setEarlyInstance($objectName, $instance) {
207 $this->earlyInstances[$objectName] = $instance;
208 }
209
210 /**
211 * Returns an instance which was registered earlier through setEarlyInstance()
212 *
213 * @param string $objectName Object name of the registered instance
214 * @return object
215 * @throws \TYPO3\CMS\Core\Exception
216 */
217 public function getEarlyInstance($objectName) {
218 if (!isset($this->earlyInstances[$objectName])) {
219 throw new \TYPO3\CMS\Core\Exception('Unknown early instance "' . $objectName . '"', 1365167380);
220 }
221 return $this->earlyInstances[$objectName];
222 }
223
224 /**
225 * Returns all registered early instances indexed by object name
226 *
227 * @return array
228 */
229 public function getEarlyInstances() {
230 return $this->earlyInstances;
231 }
232
233 /**
234 * Includes LocalConfiguration.php and sets several
235 * global settings depending on configuration.
236 *
237 * @param boolean $allowCaching Whether to allow caching - affects cache_core (autoloader)
238 * @param string $packageManagerClassName Define an alternative package manager implementation (usually for the installer)
239 * @return Bootstrap
240 * @internal This is not a public API method, do not use in own extensions
241 */
242 public function loadConfigurationAndInitialize($allowCaching = TRUE, $packageManagerClassName = 'TYPO3\\CMS\\Core\\Package\\PackageManager') {
243 $this->initializeClassLoader()
244 ->populateLocalConfiguration();
245 if (!$allowCaching) {
246 $this->disableCoreAndClassesCache();
247 }
248 $this->initializeCachingFramework()
249 ->initializeClassLoaderCaches()
250 ->initializePackageManagement($packageManagerClassName)
251 ->initializeRuntimeActivatedPackagesFromConfiguration();
252
253 $this->defineDatabaseConstants()
254 ->defineUserAgentConstant()
255 ->registerExtDirectComponents()
256 ->transferDeprecatedCurlSettings()
257 ->setCacheHashOptions()
258 ->setDefaultTimezone()
259 ->initializeL10nLocales()
260 ->convertPageNotFoundHandlingToBoolean()
261 ->registerGlobalDebugFunctions()
262 // SwiftMailerAdapter is
263 // @deprecated since 6.1, will be removed two versions later - will be removed together with \TYPO3\CMS\Core\Utility\MailUtility::mail()
264 ->registerSwiftMailer()
265 ->configureExceptionHandling()
266 ->initializeExceptionHandling()
267 ->setMemoryLimit()
268 ->defineTypo3RequestTypes();
269 return $this;
270 }
271
272 /**
273 * Initializes the Class Loader
274 *
275 * @return Bootstrap
276 * @internal This is not a public API method, do not use in own extensions
277 */
278 public function initializeClassLoader() {
279 $classLoader = new ClassLoader($this->applicationContext);
280 $this->setEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader', $classLoader);
281 $classLoader->setRuntimeClassLoadingInformationFromAutoloadRegistry((array) include __DIR__ . '/../../ext_autoload.php');
282 $classAliasMap = new ClassAliasMap();
283 $classAliasMap->injectClassLoader($classLoader);
284 $classAliasMap->injectComposerClassLoader($this->getEarlyInstance('Composer\\Autoload\\ClassLoader'));
285 $this->setEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassAliasMap', $classAliasMap);
286 $classLoader->injectClassAliasMap($classAliasMap);
287 spl_autoload_register(array($classLoader, 'loadClass'), TRUE, FALSE);
288 return $this;
289 }
290
291 /**
292 * Unregister class loader
293 *
294 * @return Bootstrap
295 * @internal This is not a public API method, do not use in own extensions
296 */
297 public function unregisterClassLoader() {
298 $currentClassLoader = $this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader');
299 spl_autoload_unregister(array($currentClassLoader, 'loadClass'));
300 return $this;
301 }
302
303 /**
304 * Initialize class loader cache.
305 *
306 * @return Bootstrap
307 * @internal This is not a public API method, do not use in own extensions
308 */
309 public function initializeClassLoaderCaches() {
310 /** @var $classLoader ClassLoader */
311 $classLoader = $this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader');
312 $classLoader->injectCoreCache($this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_core'));
313 $classLoader->injectClassesCache($this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_classes'));
314 return $this;
315 }
316
317 /**
318 * Initializes the package system and loads the package configuration and settings
319 * provided by the packages.
320 *
321 * @param string $packageManagerClassName Define an alternative package manager implementation (usually for the installer)
322 * @return Bootstrap
323 * @internal This is not a public API method, do not use in own extensions
324 */
325 public function initializePackageManagement($packageManagerClassName) {
326 /** @var \TYPO3\CMS\Core\Package\PackageManager $packageManager */
327 $packageManager = new $packageManagerClassName();
328 $this->setEarlyInstance('TYPO3\\Flow\\Package\\PackageManager', $packageManager);
329 Utility\ExtensionManagementUtility::setPackageManager($packageManager);
330 $packageManager->injectClassLoader($this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader'));
331 $packageManager->injectCoreCache($this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_core'));
332 $packageManager->injectDependencyResolver(Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Package\\DependencyResolver'));
333 $packageManager->initialize($this);
334 Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Package\\PackageManager', $packageManager);
335 return $this;
336 }
337
338 /**
339 * Activates a package during runtime. This is used in AdditionalConfiguration.php
340 * to enable extensions under conditions.
341 *
342 * @return Bootstrap
343 */
344 protected function initializeRuntimeActivatedPackagesFromConfiguration() {
345 if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages'])) {
346 /** @var \TYPO3\CMS\Core\Package\PackageManager $packageManager */
347 $packageManager = $this->getEarlyInstance('TYPO3\\Flow\\Package\\PackageManager');
348 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages'] as $runtimeAddedPackageKey) {
349 $packageManager->activatePackageDuringRuntime($runtimeAddedPackageKey);
350 }
351 }
352 return $this;
353 }
354
355 /**
356 * Load ext_localconf of extensions
357 *
358 * @param boolean $allowCaching
359 * @return Bootstrap
360 * @internal This is not a public API method, do not use in own extensions
361 */
362 public function loadTypo3LoadedExtAndExtLocalconf($allowCaching = TRUE) {
363 $this->loadAdditionalConfigurationFromExtensions($allowCaching);
364 return $this;
365 }
366
367 /**
368 * Sets up additional configuration applied in all scopes
369 *
370 * @return Bootstrap
371 * @internal This is not a public API method, do not use in own extensions
372 */
373 public function applyAdditionalConfigurationSettings() {
374 $this->initializeExceptionHandling()
375 ->setFinalCachingFrameworkCacheConfiguration()
376 ->defineLoggingAndExceptionConstants()
377 ->unsetReservedGlobalVariables();
378 return $this;
379 }
380
381 /**
382 * Throws an exception if no browser could be identified
383 *
384 * @return Bootstrap
385 * @throws \RuntimeException
386 * @internal This is not a public API method, do not use in own extensions
387 */
388 public function checkValidBrowserOrDie() {
389 // Checks for proper browser
390 if (empty($GLOBALS['CLIENT']['BROWSER'])) {
391 throw new \RuntimeException('Browser Error: Your browser version looks incompatible with this TYPO3 version!', 1294587023);
392 }
393 return $this;
394 }
395
396 /**
397 * We need an early instance of the configuration manager.
398 * Since makeInstance relies on the object configuration, we create it here with new instead.
399 *
400 * @return Bootstrap
401 */
402 public function populateLocalConfiguration() {
403 try {
404 $configurationManager = $this->getEarlyInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
405 } catch(\TYPO3\CMS\Core\Exception $exception) {
406 $configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager();
407 $this->setEarlyInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager', $configurationManager);
408 }
409 $configurationManager->exportConfiguration();
410 return $this;
411 }
412
413 /**
414 * Set cache_core to null backend, effectively disabling eg. the autoloader cache
415 *
416 * @return \TYPO3\CMS\Core\Core\Bootstrap
417 * @internal This is not a public API method, do not use in own extensions
418 */
419 public function disableCoreAndClassesCache() {
420 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_core']['backend']
421 = 'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend';
422 unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_core']['options']);
423 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_classes']['backend']
424 = 'TYPO3\\CMS\\Core\\Cache\\Backend\\TransientMemoryBackend';
425 unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_classes']['options']);
426 return $this;
427 }
428
429 /**
430 * Define database constants
431 *
432 * @return \TYPO3\CMS\Core\Core\Bootstrap
433 */
434 protected function defineDatabaseConstants() {
435 define('TYPO3_db', $GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
436 define('TYPO3_db_username', $GLOBALS['TYPO3_CONF_VARS']['DB']['username']);
437 define('TYPO3_db_password', $GLOBALS['TYPO3_CONF_VARS']['DB']['password']);
438 define('TYPO3_db_host', $GLOBALS['TYPO3_CONF_VARS']['DB']['host']);
439 define('TYPO3_extTableDef_script',
440 isset($GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript'])
441 ? $GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript']
442 : 'extTables.php');
443 return $this;
444 }
445
446 /**
447 * Define user agent constant
448 *
449 * @return \TYPO3\CMS\Core\Core\Bootstrap
450 */
451 protected function defineUserAgentConstant() {
452 define('TYPO3_user_agent', 'User-Agent: ' . $GLOBALS['TYPO3_CONF_VARS']['HTTP']['userAgent']);
453 return $this;
454 }
455
456 /**
457 * Register default ExtDirect components
458 *
459 * @return Bootstrap
460 */
461 protected function registerExtDirectComponents() {
462 if (TYPO3_MODE === 'BE') {
463 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.DataProvider', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeDataProvider', 'web', 'user,group');
464 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.Commands', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeCommands', 'web', 'user,group');
465 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.ContextMenuDataProvider', 'TYPO3\\CMS\\Backend\\ContextMenu\\Pagetree\\Extdirect\\ContextMenuConfiguration', 'web', 'user,group');
466 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.LiveSearchActions.ExtDirect', 'TYPO3\\CMS\\Backend\\Search\\LiveSearch\\ExtDirect\\LiveSearchDataProvider', 'web_list', 'user,group');
467 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.BackendUserSettings.ExtDirect', 'TYPO3\\CMS\\Backend\\User\\ExtDirect\\BackendUserSettingsDataProvider');
468 if (Utility\ExtensionManagementUtility::isLoaded('context_help')) {
469 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.CSH.ExtDirect', 'TYPO3\\CMS\\ContextHelp\\ExtDirect\\ContextHelpDataProvider');
470 }
471 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.ExtDirectStateProvider.ExtDirect', 'TYPO3\\CMS\\Backend\\InterfaceState\\ExtDirect\\DataProvider');
472 Utility\ExtensionManagementUtility::registerExtDirectComponent(
473 'TYPO3.Components.DragAndDrop.CommandController',
474 Utility\ExtensionManagementUtility::extPath('backend') . 'Classes/View/PageLayout/Extdirect/ExtdirectPageCommands.php:TYPO3\\CMS\\Backend\\View\\PageLayout\\ExtDirect\\ExtdirectPageCommands', 'web', 'user,group'
475 );
476 }
477 return $this;
478 }
479
480 /**
481 * Initialize caching framework
482 *
483 * @return Bootstrap
484 * @internal This is not a public API method, do not use in own extensions
485 */
486 public function initializeCachingFramework() {
487 $this->setEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework());
488 // @deprecated since 6.2 will be removed in two versions
489 $GLOBALS['typo3CacheManager'] = new \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator('TYPO3\\CMS\\Core\\Cache\\CacheManager');
490 $GLOBALS['typo3CacheFactory'] = new \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator('TYPO3\\CMS\\Core\\Cache\\CacheFactory');
491 return $this;
492 }
493
494 /**
495 * Parse old curl options and set new http ones instead
496 *
497 * @TODO: Move this functionality to the silent updater in the Install Tool
498 * @return Bootstrap
499 */
500 protected function transferDeprecatedCurlSettings() {
501 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']) && empty($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'])) {
502 $curlProxy = rtrim(preg_replace('#^https?://#', '', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']), '/');
503 $proxyParts = Utility\GeneralUtility::revExplode(':', $curlProxy, 2);
504 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = $proxyParts[0];
505 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port'] = $proxyParts[1];
506 }
507 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass']) && empty($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'])) {
508 $userPassParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'], 2);
509 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'] = $userPassParts[0];
510 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_password'] = $userPassParts[1];
511 }
512 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse']) {
513 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['adapter'] = 'curl';
514 }
515 return $this;
516 }
517
518 /**
519 * Set cacheHash options
520 *
521 * @return Bootstrap
522 */
523 protected function setCacheHashOptions() {
524 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] = array(
525 'cachedParametersWhiteList' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashOnlyForParameters'], TRUE),
526 'excludedParameters' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'], TRUE),
527 'requireCacheHashPresenceParameters' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashRequiredParameters'], TRUE)
528 );
529 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty']) === '*') {
530 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludeAllEmptyParameters'] = TRUE;
531 } else {
532 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParametersIfEmpty'] = Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty'], TRUE);
533 }
534 return $this;
535 }
536
537 /**
538 * Set default timezone
539 *
540 * @return Bootstrap
541 */
542 protected function setDefaultTimezone() {
543 $timeZone = $GLOBALS['TYPO3_CONF_VARS']['SYS']['phpTimeZone'];
544 if (empty($timeZone)) {
545 // Time zone from the server environment (TZ env or OS query)
546 $defaultTimeZone = @date_default_timezone_get();
547 if ($defaultTimeZone !== '') {
548 $timeZone = $defaultTimeZone;
549 } else {
550 $timeZone = 'UTC';
551 }
552 }
553 // Set default to avoid E_WARNINGs with PHP > 5.3
554 date_default_timezone_set($timeZone);
555 return $this;
556 }
557
558 /**
559 * Initialize the locales handled by TYPO3
560 *
561 * @return Bootstrap
562 */
563 protected function initializeL10nLocales() {
564 \TYPO3\CMS\Core\Localization\Locales::initialize();
565 return $this;
566 }
567
568 /**
569 * Convert type of "pageNotFound_handling" setting in case it was written as a
570 * string (e.g. if edited in Install Tool)
571 *
572 * @TODO : Remove, if the Install Tool handles such data types correctly
573 * @return Bootstrap
574 */
575 protected function convertPageNotFoundHandlingToBoolean() {
576 if (!strcasecmp($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'], 'TRUE')) {
577 $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = TRUE;
578 }
579 return $this;
580 }
581
582 /**
583 * Register xdebug(), debug(), debugBegin() and debugEnd() as global functions
584 *
585 * Note: Yes, this is possible in php! xdebug() is then a global function, even
586 * if registerGlobalDebugFunctions() is encapsulated in class scope.
587 *
588 * @return Bootstrap
589 */
590 protected function registerGlobalDebugFunctions() {
591 require_once('GlobalDebugFunctions.php');
592 return $this;
593 }
594
595 /**
596 * Mail sending via Swift Mailer
597 *
598 * @return \TYPO3\CMS\Core\Core\Bootstrap
599 * @deprecated since 6.1, will be removed two versions later - will be removed together with \TYPO3\CMS\Core\Utility\MailUtility::mail()
600 */
601 protected function registerSwiftMailer() {
602 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'][] =
603 'TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter';
604 return $this;
605 }
606
607 /**
608 * Configure and set up exception and error handling
609 *
610 * @return Bootstrap
611 */
612 protected function configureExceptionHandling() {
613 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
614 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'];
615 $doesIpMatch = Utility\GeneralUtility::cmpIP(Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
616 $displayErrors = (int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'];
617 // Turn error logging on/off.
618 if ($displayErrors !== -1) {
619 // Special value "2" enables this feature only if $GLOBALS['TYPO3_CONF_VARS'][SYS][devIPmask] matches
620 if ($displayErrors === 2) {
621 $displayErrors = (int)$doesIpMatch;
622 }
623 if ($displayErrors === 0) {
624 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = 0;
625 }
626 if ($displayErrors === 1) {
627 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
628 define('TYPO3_ERRORHANDLER_MODE', 'debug');
629 }
630 @ini_set('display_errors', $displayErrors);
631 } elseif ($doesIpMatch) {
632 // With displayErrors = -1 (default), turn on debugging if devIPmask matches:
633 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
634 }
635 return $this;
636 }
637
638 /**
639 * Set PHP memory limit depending on value of
640 * $GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']
641 *
642 * @return Bootstrap
643 */
644 protected function setMemoryLimit() {
645 if ((int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit'] > 16) {
646 @ini_set('memory_limit', ((int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit'] . 'm'));
647 }
648 return $this;
649 }
650
651 /**
652 * Define TYPO3_REQUESTTYPE* constants
653 * so devs exactly know what type of request it is
654 *
655 * @return Bootstrap
656 */
657 protected function defineTypo3RequestTypes() {
658 define('TYPO3_REQUESTTYPE_FE', 1);
659 define('TYPO3_REQUESTTYPE_BE', 2);
660 define('TYPO3_REQUESTTYPE_CLI', 4);
661 define('TYPO3_REQUESTTYPE_AJAX', 8);
662 define('TYPO3_REQUESTTYPE_INSTALL', 16);
663 define('TYPO3_REQUESTTYPE', (TYPO3_MODE == 'FE' ? TYPO3_REQUESTTYPE_FE : 0) | (TYPO3_MODE == 'BE' ? TYPO3_REQUESTTYPE_BE : 0) | (defined('TYPO3_cliMode') && TYPO3_cliMode ? TYPO3_REQUESTTYPE_CLI : 0) | (defined('TYPO3_enterInstallScript') && TYPO3_enterInstallScript ? TYPO3_REQUESTTYPE_INSTALL : 0) | ($GLOBALS['TYPO3_AJAX'] ? TYPO3_REQUESTTYPE_AJAX : 0));
664 return $this;
665 }
666
667 /**
668 * Load extension configuration files (ext_localconf.php)
669 *
670 * The ext_localconf.php files in extensions are meant to make changes
671 * to the global $TYPO3_CONF_VARS configuration array.
672 *
673 * @param boolean $allowCaching
674 * @return Bootstrap
675 */
676 protected function loadAdditionalConfigurationFromExtensions($allowCaching = TRUE) {
677 Utility\ExtensionManagementUtility::loadExtLocalconf($allowCaching);
678 return $this;
679 }
680
681 /**
682 * Initialize exception handling
683 * This method is called twice. First when LocalConfiguration has been loaded
684 * and a second time after extension ext_loclconf.php have been included to allow extensions
685 * to change the exception and error handler configuration.
686 *
687 * @return Bootstrap
688 */
689 protected function initializeExceptionHandling() {
690 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'])) {
691 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'])) {
692 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'] !== $this->activeErrorHandlerClassName) {
693 $this->activeErrorHandlerClassName = $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'];
694 // Register an error handler for the given errorHandlerErrors
695 $errorHandler = Utility\GeneralUtility::makeInstance($this->activeErrorHandlerClassName, $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors']);
696 // Set errors which will be converted in an exception
697 $errorHandler->setExceptionalErrors($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors']);
698 }
699 } elseif (!empty($this->activeErrorHandlerClassName)) {
700 // Restore error handler in case extensions have unset the configuration in ext_localconf.php
701 restore_error_handler();
702 }
703 if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] !== $this->activeExceptionHandlerClassName) {
704 $this->activeExceptionHandlerClassName = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'];
705 // Registering the exception handler is done in the constructor
706 Utility\GeneralUtility::makeInstance($this->activeExceptionHandlerClassName);
707 }
708 } elseif (!empty($this->activeExceptionHandlerClassName)) {
709 // Restore exception handler in case extensions have unset the configuration in ext_localconf.php
710 restore_exception_handler();
711 }
712 return $this;
713 }
714
715 /**
716 * Extensions may register new caches, so we set the
717 * global cache array to the manager again at this point
718 *
719 * @return Bootstrap
720 */
721 protected function setFinalCachingFrameworkCacheConfiguration() {
722 $this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
723 return $this;
724 }
725
726 /**
727 * Define logging and exception constants
728 *
729 * @return Bootstrap
730 */
731 protected function defineLoggingAndExceptionConstants() {
732 define('TYPO3_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']);
733 define('TYPO3_ERROR_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG']);
734 define('TYPO3_EXCEPTION_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG']);
735 return $this;
736 }
737
738 /**
739 * Unsetting reserved global variables:
740 * Those are set in "ext:core/ext_tables.php" file:
741 *
742 * @return Bootstrap
743 */
744 protected function unsetReservedGlobalVariables() {
745 unset($GLOBALS['PAGES_TYPES']);
746 unset($GLOBALS['TCA']);
747 unset($GLOBALS['TBE_MODULES']);
748 unset($GLOBALS['TBE_STYLES']);
749 unset($GLOBALS['FILEICONS']);
750 // Those set in init.php:
751 unset($GLOBALS['WEBMOUNTS']);
752 unset($GLOBALS['BE_USER']);
753 // Those set otherwise:
754 unset($GLOBALS['TBE_MODULES_EXT']);
755 unset($GLOBALS['TCA_DESCR']);
756 unset($GLOBALS['LOCAL_LANG']);
757 unset($GLOBALS['TYPO3_AJAX']);
758 return $this;
759 }
760
761 /**
762 * Initialize database connection in $GLOBALS and connect if requested
763 *
764 * @return \TYPO3\CMS\Core\Core\Bootstrap
765 * @internal This is not a public API method, do not use in own extensions
766 */
767 public function initializeTypo3DbGlobal() {
768 /** @var $databaseConnection \TYPO3\CMS\Core\Database\DatabaseConnection */
769 $databaseConnection = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
770 $databaseConnection->setDatabaseName(TYPO3_db);
771 $databaseConnection->setDatabaseUsername(TYPO3_db_username);
772 $databaseConnection->setDatabasePassword(TYPO3_db_password);
773
774 $databaseHost = TYPO3_db_host;
775 if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['port'])) {
776 $databaseConnection->setDatabasePort($GLOBALS['TYPO3_CONF_VARS']['DB']['port']);
777 } elseif (strpos($databaseHost, ':') > 0) {
778 // @TODO: Find a way to handle this case in the install tool and drop this
779 list($databaseHost, $databasePort) = explode(':', $databaseHost);
780 $databaseConnection->setDatabasePort($databasePort);
781 }
782 if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['socket'])) {
783 $databaseConnection->setDatabaseSocket($GLOBALS['TYPO3_CONF_VARS']['DB']['socket']);
784 }
785 $databaseConnection->setDatabaseHost($databaseHost);
786
787 $databaseConnection->debugOutput = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'];
788
789 if (
790 isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'])
791 && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect']
792 ) {
793 $databaseConnection->setPersistentDatabaseConnection(TRUE);
794 }
795
796 $isDatabaseHostLocalHost = $databaseHost === 'localhost' || $databaseHost === '127.0.0.1' || $databaseHost === '::1';
797 if (
798 isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['dbClientCompress'])
799 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['dbClientCompress']
800 && !$isDatabaseHostLocalHost
801 ) {
802 $databaseConnection->setConnectionCompression(TRUE);
803 }
804
805 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'])) {
806 $commandsAfterConnect = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(
807 LF,
808 str_replace('\' . LF . \'', LF, $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']),
809 TRUE
810 );
811 $databaseConnection->setInitializeCommandsAfterConnect($commandsAfterConnect);
812 }
813
814 $GLOBALS['TYPO3_DB'] = $databaseConnection;
815 // $GLOBALS['TYPO3_DB'] needs to be defined first in order to work for DBAL
816 $GLOBALS['TYPO3_DB']->initialize();
817
818 return $this;
819 }
820
821 /**
822 * Check adminOnly configuration variable and redirects
823 * to an URL in file typo3conf/LOCK_BACKEND or exit the script
824 *
825 * @throws \RuntimeException
826 * @return Bootstrap
827 * @internal This is not a public API method, do not use in own extensions
828 */
829 public function checkLockedBackendAndRedirectOrDie() {
830 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
831 throw new \RuntimeException('TYPO3 Backend locked: Backend and Install Tool are locked for maintenance. [BE][adminOnly] is set to "' . (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] . '".', 1294586847);
832 }
833 if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
834 if (TYPO3_PROCEED_IF_NO_USER === 2) {
835
836 } else {
837 $fileContent = Utility\GeneralUtility::getUrl(PATH_typo3conf . 'LOCK_BACKEND');
838 if ($fileContent) {
839 header('Location: ' . $fileContent);
840 } else {
841 throw new \RuntimeException('TYPO3 Backend locked: Browser backend is locked for maintenance. Remove lock by removing the file "typo3conf/LOCK_BACKEND" or use CLI-scripts.', 1294586848);
842 }
843 die;
844 }
845 }
846 return $this;
847 }
848
849 /**
850 * Compare client IP with IPmaskList and exit the script run
851 * if the client is not allowed to access the backend
852 *
853 * @return Bootstrap
854 * @internal This is not a public API method, do not use in own extensions
855 * @throws \RuntimeException
856 */
857 public function checkBackendIpOrDie() {
858 if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
859 if (!Utility\GeneralUtility::cmpIP(Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
860 throw new \RuntimeException('TYPO3 Backend access denied: The IP address of your client does not match the list of allowed IP addresses.', 1389265900);
861 }
862 }
863 return $this;
864 }
865
866 /**
867 * Check lockSSL configuration variable and redirect
868 * to https version of the backend if needed
869 *
870 * @return Bootstrap
871 * @internal This is not a public API method, do not use in own extensions
872 * @throws \RuntimeException
873 */
874 public function checkSslBackendAndRedirectIfNeeded() {
875 if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL']) {
876 if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort']) {
877 $sslPortSuffix = ':' . (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort'];
878 } else {
879 $sslPortSuffix = '';
880 }
881 if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] === 3) {
882 $requestStr = substr(Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT'), strlen(Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir));
883 if ($requestStr === 'index.php' && !Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
884 list(, $url) = explode('://', Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 2);
885 list($server, $address) = explode('/', $url, 2);
886 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
887 die;
888 }
889 } elseif (!Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
890 if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] === 2) {
891 list(, $url) = explode('://', Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir, 2);
892 list($server, $address) = explode('/', $url, 2);
893 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
894 die;
895 } else {
896 throw new \RuntimeException('TYPO3 Backend not accessed via SSL: TYPO3 Backend is configured to only be accessible through SSL. Change the URL in your browser and try again.', 1389265726);
897 }
898 }
899 }
900 return $this;
901 }
902
903 /**
904 * Load TCA for frontend
905 *
906 * This method is *only* executed in frontend scope. The idea is to execute the
907 * whole TCA and ext_tables (which manipulate TCA) on first frontend access,
908 * and then cache the full TCA on disk to be used for the next run again.
909 *
910 * This way, ext_tables.php ist not executed every time, but $GLOBALS['TCA']
911 * is still always there.
912 *
913 * @return Bootstrap
914 * @internal This is not a public API method, do not use in own extensions
915 */
916 public function loadCachedTca() {
917 $cacheIdentifier = 'tca_fe_' . sha1((TYPO3_version . PATH_site . 'tca_fe'));
918 /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
919 $codeCache = $this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_core');
920 if ($codeCache->has($cacheIdentifier)) {
921 // substr is necessary, because the php frontend wraps php code around the cache value
922 $GLOBALS['TCA'] = unserialize(substr($codeCache->get($cacheIdentifier), 6, -2));
923 } else {
924 $this->loadExtensionTables(TRUE);
925 $codeCache->set($cacheIdentifier, serialize($GLOBALS['TCA']));
926 }
927 return $this;
928 }
929
930 /**
931 * Load ext_tables and friends.
932 *
933 * This will mainly set up $TCA and several other global arrays
934 * through API's like extMgm.
935 * Executes ext_tables.php files of loaded extensions or the
936 * according cache file if exists.
937 *
938 * @param boolean $allowCaching True, if reading compiled ext_tables file from cache is allowed
939 * @return Bootstrap
940 * @internal This is not a public API method, do not use in own extensions
941 */
942 public function loadExtensionTables($allowCaching = TRUE) {
943 Utility\ExtensionManagementUtility::loadBaseTca($allowCaching);
944 Utility\ExtensionManagementUtility::loadExtTables($allowCaching);
945 $this->executeExtTablesAdditionalFile();
946 $this->runExtTablesPostProcessingHooks();
947 return $this;
948 }
949
950 /**
951 * Execute TYPO3_extTableDef_script if defined and exists
952 *
953 * Note: For backwards compatibility some global variables are
954 * explicitly set as global to be used without $GLOBALS[] in
955 * the extension table script. It is discouraged to access variables like
956 * $TBE_MODULES directly, but we can not prohibit
957 * this without heavily breaking backwards compatibility.
958 *
959 * @TODO : We could write a scheduler / reports module or an update checker
960 * @TODO : It should be defined, which global arrays are ok to be manipulated
961 *
962 * @return void
963 */
964 protected function executeExtTablesAdditionalFile() {
965 // It is discouraged to use those global variables directly, but we
966 // can not prohibit this without breaking backwards compatibility
967 global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
968 global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
969 global $PAGES_TYPES, $TBE_STYLES, $FILEICONS;
970 global $_EXTKEY;
971 // Load additional ext tables script if the file exists
972 $extTablesFile = PATH_typo3conf . TYPO3_extTableDef_script;
973 if (file_exists($extTablesFile) && is_file($extTablesFile)) {
974 include $extTablesFile;
975 }
976 }
977
978 /**
979 * Check for registered ext tables hooks and run them
980 *
981 * @throws \UnexpectedValueException
982 * @return void
983 */
984 protected function runExtTablesPostProcessingHooks() {
985 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
986 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] as $classReference) {
987 /** @var $hookObject \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface */
988 $hookObject = Utility\GeneralUtility::getUserObj($classReference);
989 if (!$hookObject instanceof \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface) {
990 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\Database\\TableConfigurationPostProcessingHookInterface', 1320585902);
991 }
992 $hookObject->processData();
993 }
994 }
995 }
996
997 /**
998 * Initialize sprite manager
999 *
1000 * @return Bootstrap
1001 * @internal This is not a public API method, do not use in own extensions
1002 */
1003 public function initializeSpriteManager() {
1004 \TYPO3\CMS\Backend\Sprite\SpriteManager::initialize();
1005 return $this;
1006 }
1007
1008 /**
1009 * Initialize backend user object in globals
1010 *
1011 * @return Bootstrap
1012 * @internal This is not a public API method, do not use in own extensions
1013 */
1014 public function initializeBackendUser() {
1015 /** @var $backendUser \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */
1016 $backendUser = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
1017 $backendUser->warningEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
1018 $backendUser->lockIP = $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'];
1019 $backendUser->auth_timeout_field = (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'];
1020 $backendUser->OS = TYPO3_OS;
1021 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
1022 $backendUser->dontSetCookie = TRUE;
1023 }
1024 // The global must be available very early, because methods below
1025 // might trigger code which relies on it. See: #45625
1026 $GLOBALS['BE_USER'] = $backendUser;
1027 $backendUser->start();
1028 return $this;
1029 }
1030
1031 /**
1032 * Initializes and ensures authenticated access
1033 *
1034 * @internal This is not a public API method, do not use in own extensions
1035 * @return \TYPO3\CMS\Core\Core\Bootstrap
1036 */
1037 public function initializeBackendAuthentication() {
1038 $GLOBALS['BE_USER']->checkCLIuser();
1039 $GLOBALS['BE_USER']->backendCheckLogin();
1040 return $this;
1041 }
1042
1043 /**
1044 * Initialize backend user mount points
1045 *
1046 * @return Bootstrap
1047 * @internal This is not a public API method, do not use in own extensions
1048 */
1049 public function initializeBackendUserMounts() {
1050 // Includes deleted mount pages as well! @TODO: Figure out why ...
1051 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
1052 return $this;
1053 }
1054
1055 /**
1056 * Initialize language object
1057 *
1058 * @return Bootstrap
1059 * @internal This is not a public API method, do not use in own extensions
1060 */
1061 public function initializeLanguageObject() {
1062 /** @var $GLOBALS['LANG'] \TYPO3\CMS\Lang\LanguageService */
1063 $GLOBALS['LANG'] = Utility\GeneralUtility::makeInstance('TYPO3\CMS\Lang\LanguageService');
1064 $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
1065 return $this;
1066 }
1067
1068 /**
1069 * Throw away all output that may have happened during bootstrapping by weird extensions
1070 *
1071 * @return Bootstrap
1072 * @internal This is not a public API method, do not use in own extensions
1073 */
1074 public function endOutputBufferingAndCleanPreviousOutput() {
1075 ob_clean();
1076 return $this;
1077 }
1078
1079 /**
1080 * Initialize output compression if configured
1081 *
1082 * @return Bootstrap
1083 * @internal This is not a public API method, do not use in own extensions
1084 */
1085 public function initializeOutputCompression() {
1086 if (extension_loaded('zlib') && $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']) {
1087 if (Utility\MathUtility::canBeInterpretedAsInteger($GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'])) {
1088 @ini_set('zlib.output_compression_level', $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']);
1089 }
1090 ob_start('ob_gzhandler');
1091 }
1092 return $this;
1093 }
1094
1095 /**
1096 * Send HTTP headers if configured
1097 *
1098 * @return Bootstrap
1099 * @internal This is not a public API method, do not use in own extensions
1100 */
1101 public function sendHttpHeaders() {
1102 if (!empty($GLOBALS['TYPO3_CONF_VARS']['BE']['HTTP']['Response']['Headers']) && is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['HTTP']['Response']['Headers'])) {
1103 foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['HTTP']['Response']['Headers'] as $header) {
1104 header($header);
1105 }
1106 }
1107 return $this;
1108 }
1109
1110 /**
1111 * Things that should be performed to shut down the framework.
1112 * This method is called in all important scripts for a clean
1113 * shut down of the system.
1114 *
1115 * @return Bootstrap
1116 * @internal This is not a public API method, do not use in own extensions
1117 */
1118 public function shutdown() {
1119 return $this;
1120 }
1121
1122 /**
1123 * Provides an instance of "template" for backend-modules to
1124 * work with.
1125 *
1126 * @return Bootstrap
1127 * @internal This is not a public API method, do not use in own extensions
1128 */
1129 public function initializeBackendTemplate() {
1130 $GLOBALS['TBE_TEMPLATE'] = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
1131 return $this;
1132 }
1133 }