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