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