[TASK] Replace TCA cache with serialized array
[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 textfile 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 __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 \TYPO3\CMS\Core\Core\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
226 ->initializeClassLoader()
227 ->populateLocalConfiguration()
228 ->initializeCachingFramework()
229 ->initializeClassLoaderCache()
230 ->initializePackageManagement($packageManagerClassName);
231
232 // @TODO dig into this
233 if (!$allowCaching) {
234 $this->setCoreCacheToNullBackend();
235 }
236
237 $this->defineDatabaseConstants()
238 ->defineUserAgentConstant()
239 ->registerExtDirectComponents()
240 ->checkUtf8DatabaseSettingsOrDie()
241 ->transferDeprecatedCurlSettings()
242 ->setCacheHashOptions()
243 ->setDefaultTimezone()
244 ->initializeL10nLocales()
245 ->convertPageNotFoundHandlingToBoolean()
246 ->registerGlobalDebugFunctions()
247 // SwiftMailerAdapter is
248 // @deprecated since 6.1, will be removed two versions later - will be removed together with \TYPO3\CMS\Core\Utility\MailUtility::mail()
249 ->registerSwiftMailer()
250 ->configureExceptionHandling()
251 ->setMemoryLimit()
252 ->defineTypo3RequestTypes();
253 return $this;
254 }
255
256 /**
257 * Initializes the Class Loader
258 *
259 * @return Bootstrap
260 */
261 protected function initializeClassLoader() {
262 $classLoader = new \TYPO3\CMS\Core\Core\ClassLoader();
263 $this->setEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader', $classLoader);
264 $classLoader->setEarlyClassFileAutoloadRegistry((array) include __DIR__ . '/../../ext_autoload.php');
265 $classAliasMap = new \TYPO3\CMS\Core\Core\ClassAliasMap();
266 $classAliasMap->injectClassLoader($classLoader);
267 $this->setEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassAliasMap', $classAliasMap);
268 $classLoader->injectClassAliasMap($classAliasMap);
269 spl_autoload_register(array($classLoader, 'loadClass'), TRUE, TRUE);
270 return $this;
271 }
272
273 /**
274 * Reinitializes the class loader during clear cache actions
275 * Beware! This is not public API and necessary for edge cases in the install tool
276 *
277 * @return void
278 */
279 public function reinitializeClassLoaderAndCachesAndPackageManagement($packageManagerClassName = 'TYPO3\\CMS\\Core\\Package\\PackageManager') {
280 $currentClassLoader = $this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader');
281 spl_autoload_unregister(array($currentClassLoader, 'loadClass'));
282 \TYPO3\CMS\Core\Cache\Cache::flagCachingFrameworkForReinitialization();
283 $this
284 ->initializeClassLoader()
285 ->populateLocalConfiguration()
286 ->initializeCachingFramework()
287 ->initializeClassLoaderCache()
288 ->initializePackageManagement($packageManagerClassName);
289 }
290
291 /**
292 * Initialize class loader cache.
293 *
294 * @return Bootstrap
295 */
296 protected function initializeClassLoaderCache() {
297 /** @var $classLoader \TYPO3\CMS\Core\Core\ClassLoader */
298 $classLoader = $this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader');
299 $classLoader->injectClassesCache($this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_classes'));
300 return $this;
301 }
302
303 /**
304 * Initializes the package system and loads the package configuration and settings
305 * provided by the packages.
306 *
307 * @param string $packageManagerClassName Define an alternative package manager implementation (usually for the installer)
308 * @return Bootstrap
309 */
310 protected function initializePackageManagement($packageManagerClassName) {
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->initialize($this, PATH_site);
317 Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Package\\PackageManager', $packageManager);
318 $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($packageManager);
319 return $this;
320 }
321
322 /**
323 * Load ext_localconf of extensions
324 *
325 * @param boolean $allowCaching
326 * @return Bootstrap
327 * @internal This is not a public API method, do not use in own extensions
328 */
329 public function loadTypo3LoadedExtAndExtLocalconf($allowCaching = TRUE) {
330 $this->getInstance()
331 ->loadAdditionalConfigurationFromExtensions($allowCaching);
332 return $this;
333 }
334
335 /**
336 * Load TYPO3_LOADED_EXT, recreate class loader registry and load ext_localconf
337 *
338 * @TODO: This method was changed with the package manager patch, do we still need it?
339 * @param boolean $allowCaching
340 * @return Bootstrap
341 * @internal This is not a public API method, do not use in own extensions
342 */
343 public function reloadTypo3LoadedExtAndClassLoaderAndExtLocalconf() {
344 $bootstrap = $this->getInstance();
345 // Commented out for package management patch, method is still used in extensionmanager
346 // $bootstrap->populateTypo3LoadedExtGlobal(FALSE);
347 // \TYPO3\CMS\Core\Core\ClassLoader::loadClassLoaderCache();
348 $bootstrap->loadAdditionalConfigurationFromExtensions(FALSE);
349 return $this;
350 }
351
352 /**
353 * Sets up additional configuration applied in all scopes
354 *
355 * @return Bootstrap
356 * @internal This is not a public API method, do not use in own extensions
357 */
358 public function applyAdditionalConfigurationSettings() {
359 $this->getInstance()
360 ->initializeExceptionHandling()
361 ->setFinalCachingFrameworkCacheConfiguration()
362 ->defineLoggingAndExceptionConstants()
363 ->unsetReservedGlobalVariables();
364 return $this;
365 }
366
367 /**
368 * Throws an exception if no browser could be identified
369 *
370 * @return Bootstrap
371 * @throws \RuntimeException
372 * @internal This is not a public API method, do not use in own extensions
373 */
374 public function checkValidBrowserOrDie() {
375 // Checks for proper browser
376 if (empty($GLOBALS['CLIENT']['BROWSER'])) {
377 throw new \RuntimeException('Browser Error: Your browser version looks incompatible with this TYPO3 version!', 1294587023);
378 }
379 return $this;
380 }
381
382 /**
383 * We need an early instance of the configuration manager.
384 * Since makeInstance relies on the object configuration, we create it here with new instead.
385 *
386 * @return Bootstrap
387 */
388 public function populateLocalConfiguration() {
389 $configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager();
390 $this->setEarlyInstance('TYPO3\CMS\Core\Configuration\ConfigurationManager', $configurationManager);
391 $configurationManager->exportConfiguration();
392 return $this;
393 }
394
395 /**
396 * Set cache_core to null backend, effectively disabling eg. the autoloader cache
397 *
398 * @return \TYPO3\CMS\Core\Core\Bootstrap
399 * @internal This is not a public API method, do not use in own extensions
400 */
401 public function setCoreCacheToNullBackend() {
402 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_core']['backend']
403 = 'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend';
404 return $this;
405 }
406
407 /**
408 * Define database constants
409 *
410 * @return \TYPO3\CMS\Core\Core\Bootstrap
411 */
412 protected function defineDatabaseConstants() {
413 define('TYPO3_db', $GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
414 define('TYPO3_db_username', $GLOBALS['TYPO3_CONF_VARS']['DB']['username']);
415 define('TYPO3_db_password', $GLOBALS['TYPO3_CONF_VARS']['DB']['password']);
416 define('TYPO3_db_host', $GLOBALS['TYPO3_CONF_VARS']['DB']['host']);
417 define('TYPO3_extTableDef_script',
418 isset($GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript'])
419 ? $GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript']
420 : 'extTables.php');
421 return $this;
422 }
423
424 /**
425 * Define user agent constant
426 *
427 * @return \TYPO3\CMS\Core\Core\Bootstrap
428 */
429 protected function defineUserAgentConstant() {
430 define('TYPO3_user_agent', 'User-Agent: ' . $GLOBALS['TYPO3_CONF_VARS']['HTTP']['userAgent']);
431 return $this;
432 }
433
434 /**
435 * Register default ExtDirect components
436 *
437 * @return Bootstrap
438 */
439 protected function registerExtDirectComponents() {
440 if (TYPO3_MODE === 'BE') {
441 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.DataProvider', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeDataProvider', 'web', 'user,group');
442 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.Commands', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeCommands', 'web', 'user,group');
443 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.ContextMenuDataProvider', 'TYPO3\\CMS\\Backend\\ContextMenu\\Pagetree\\Extdirect\\ContextMenuConfiguration', 'web', 'user,group');
444 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.LiveSearchActions.ExtDirect', 'TYPO3\\CMS\\Backend\\Search\\LiveSearch\\ExtDirect\\LiveSearchDataProvider', 'web_list', 'user,group');
445 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.BackendUserSettings.ExtDirect', 'TYPO3\\CMS\\Backend\\User\\ExtDirect\\BackendUserSettingsDataProvider');
446 if (Utility\ExtensionManagementUtility::isLoaded('context_help')) {
447 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.CSH.ExtDirect', 'TYPO3\\CMS\\ContextHelp\\ExtDirect\\ContextHelpDataProvider');
448 }
449 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.ExtDirectStateProvider.ExtDirect', 'TYPO3\\CMS\\Backend\\InterfaceState\\ExtDirect\\DataProvider');
450 Utility\ExtensionManagementUtility::registerExtDirectComponent(
451 'TYPO3.Components.DragAndDrop.CommandController',
452 Utility\ExtensionManagementUtility::extPath('backend') . 'Classes/View/PageLayout/Extdirect/ExtdirectPageCommands.php:TYPO3\\CMS\\Backend\\View\\PageLayout\\ExtDirect\\ExtdirectPageCommands', 'web', 'user,group'
453 );
454 }
455 return $this;
456 }
457
458 /**
459 * Initialize caching framework
460 *
461 * @return Bootstrap
462 */
463 protected function initializeCachingFramework() {
464 // @todo Please deuglify
465 \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework();
466 $this->setEarlyInstance('TYPO3\CMS\Core\Cache\CacheManager', $GLOBALS['typo3CacheManager']);
467 return $this;
468 }
469
470 /**
471 * Checking for UTF-8 in the settings since TYPO3 4.5
472 *
473 * Since TYPO3 4.5, everything other than UTF-8 is deprecated.
474 *
475 * [SYS][setDBinit] is used to set the DB connection
476 * and both settings need to be adjusted for UTF-8 in order to work properly
477 *
478 * @return Bootstrap
479 */
480 protected function checkUtf8DatabaseSettingsOrDie() {
481 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']) &&
482 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] !== '-1' &&
483 preg_match('/SET NAMES [\'"]?utf8[\'"]?/i', $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']) === FALSE &&
484 TYPO3_enterInstallScript !== '1') {
485
486 // Only accept "SET NAMES utf8" for this setting, otherwise die with a nice error
487 die('This TYPO3 installation is using the $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'setDBinit\'] property with the following value:' . chr(10) .
488 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] . chr(10) . chr(10) .
489 'It looks like UTF-8 is not used for this connection.' . chr(10) . chr(10) .
490 'Everything other than UTF-8 is unsupported since TYPO3 4.7.' . chr(10) .
491 'The DB, its connection and TYPO3 should be migrated to UTF-8 therefore. Please check your setup.'
492 );
493 } else {
494 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] = 'SET NAMES utf8;';
495 }
496 return $this;
497 }
498
499 /**
500 * Parse old curl options and set new http ones instead
501 *
502 * @TODO: This code segment must still be finished
503 * @return Bootstrap
504 */
505 protected function transferDeprecatedCurlSettings() {
506 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'])) {
507 $proxyParts = Utility\GeneralUtility::revExplode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'], 2);
508 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = $proxyParts[0];
509 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port'] = $proxyParts[1];
510 }
511 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'])) {
512 $userPassParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'], 2);
513 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'] = $userPassParts[0];
514 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_password'] = $userPassParts[1];
515 }
516 return $this;
517 }
518
519 /**
520 * Set cacheHash options
521 *
522 * @return Bootstrap
523 */
524 protected function setCacheHashOptions() {
525 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] = array(
526 'cachedParametersWhiteList' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashOnlyForParameters'], TRUE),
527 'excludedParameters' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'], TRUE),
528 'requireCacheHashPresenceParameters' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashRequiredParameters'], TRUE)
529 );
530 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty']) === '*') {
531 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludeAllEmptyParameters'] = TRUE;
532 } else {
533 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParametersIfEmpty'] = Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty'], TRUE);
534 }
535 return $this;
536 }
537
538 /**
539 * Set default timezone
540 *
541 * @return Bootstrap
542 */
543 protected function setDefaultTimezone() {
544 $timeZone = $GLOBALS['TYPO3_CONF_VARS']['SYS']['phpTimeZone'];
545 if (empty($timeZone)) {
546 // Time zone from the server environment (TZ env or OS query)
547 $defaultTimeZone = @date_default_timezone_get();
548 if ($defaultTimeZone !== '') {
549 $timeZone = $defaultTimeZone;
550 } else {
551 $timeZone = 'UTC';
552 }
553 }
554 // Set default to avoid E_WARNINGs with PHP > 5.3
555 date_default_timezone_set($timeZone);
556 return $this;
557 }
558
559 /**
560 * Initialize the locales handled by TYPO3
561 *
562 * @return Bootstrap
563 */
564 protected function initializeL10nLocales() {
565 \TYPO3\CMS\Core\Localization\Locales::initialize();
566 return $this;
567 }
568
569 /**
570 * Convert type of "pageNotFound_handling" setting in case it was written as a
571 * string (e.g. if edited in Install Tool)
572 *
573 * @TODO : Remove, if the Install Tool handles such data types correctly
574 * @return Bootstrap
575 */
576 protected function convertPageNotFoundHandlingToBoolean() {
577 if (!strcasecmp($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'], 'TRUE')) {
578 $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = TRUE;
579 }
580 return $this;
581 }
582
583 /**
584 * Register xdebug(), debug(), debugBegin() and debugEnd() as global functions
585 *
586 * Note: Yes, this is possible in php! xdebug() is then a global function, even
587 * if registerGlobalDebugFunctions() is encapsulated in class scope.
588 *
589 * @return Bootstrap
590 */
591 protected function registerGlobalDebugFunctions() {
592 require_once('GlobalDebugFunctions.php');
593 return $this;
594 }
595
596 /**
597 * Mail sending via Swift Mailer
598 *
599 * @return \TYPO3\CMS\Core\Core\Bootstrap
600 * @deprecated since 6.1, will be removed two versions later - will be removed together with \TYPO3\CMS\Core\Utility\MailUtility::mail()
601 */
602 protected function registerSwiftMailer() {
603 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'][] =
604 'TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter';
605 return $this;
606 }
607
608 /**
609 * Configure and set up exception and error handling
610 *
611 * @return Bootstrap
612 */
613 protected function configureExceptionHandling() {
614 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
615 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'];
616 // Turn error logging on/off.
617 if (($displayErrors = intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'])) != '-1') {
618 // Special value "2" enables this feature only if $GLOBALS['TYPO3_CONF_VARS'][SYS][devIPmask] matches
619 if ($displayErrors == 2) {
620 if (Utility\GeneralUtility::cmpIP(Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
621 $displayErrors = 1;
622 } else {
623 $displayErrors = 0;
624 }
625 }
626 if ($displayErrors == 0) {
627 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = 0;
628 }
629 if ($displayErrors == 1) {
630 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
631 define('TYPO3_ERRORHANDLER_MODE', 'debug');
632 }
633 @ini_set('display_errors', $displayErrors);
634 } elseif (Utility\GeneralUtility::cmpIP(Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
635 // With displayErrors = -1 (default), turn on debugging if devIPmask matches:
636 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
637 }
638 return $this;
639 }
640
641 /**
642 * Set PHP memory limit depending on value of
643 * $GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']
644 *
645 * @return Bootstrap
646 */
647 protected function setMemoryLimit() {
648 if (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) > 16) {
649 @ini_set('memory_limit', (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) . 'm'));
650 }
651 return $this;
652 }
653
654 /**
655 * Define TYPO3_REQUESTTYPE* constants
656 * so devs exactly know what type of request it is
657 *
658 * @return Bootstrap
659 */
660 protected function defineTypo3RequestTypes() {
661 define('TYPO3_REQUESTTYPE_FE', 1);
662 define('TYPO3_REQUESTTYPE_BE', 2);
663 define('TYPO3_REQUESTTYPE_CLI', 4);
664 define('TYPO3_REQUESTTYPE_AJAX', 8);
665 define('TYPO3_REQUESTTYPE_INSTALL', 16);
666 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));
667 return $this;
668 }
669
670 /**
671 * Load extension configuration files (ext_localconf.php)
672 *
673 * The ext_localconf.php files in extensions are meant to make changes
674 * to the global $TYPO3_CONF_VARS configuration array.
675 *
676 * @param boolean $allowCaching
677 * @return Bootstrap
678 */
679 protected function loadAdditionalConfigurationFromExtensions($allowCaching = TRUE) {
680 Utility\ExtensionManagementUtility::loadExtLocalconf($allowCaching);
681 return $this;
682 }
683
684 /**
685 * Initialize exception handling
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 // Register an error handler for the given errorHandlerErrors
693 $errorHandler = Utility\GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors']);
694 // Set errors which will be converted in an exception
695 $errorHandler->setExceptionalErrors($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors']);
696 }
697 // Instantiate the exception handler once to make sure object is registered
698 // @TODO: Figure out if this is really needed
699 Utility\GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler']);
700 }
701 return $this;
702 }
703
704 /**
705 * Extensions may register new caches, so we set the
706 * global cache array to the manager again at this point
707 *
708 * @return Bootstrap
709 */
710 protected function setFinalCachingFrameworkCacheConfiguration() {
711 $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
712 return $this;
713 }
714
715 /**
716 * Define logging and exception constants
717 *
718 * @return Bootstrap
719 */
720 protected function defineLoggingAndExceptionConstants() {
721 define('TYPO3_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']);
722 define('TYPO3_ERROR_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG']);
723 define('TYPO3_EXCEPTION_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG']);
724 return $this;
725 }
726
727 /**
728 * Unsetting reserved global variables:
729 * Those are set in "ext:core/ext_tables.php" file:
730 *
731 * @return Bootstrap
732 */
733 protected function unsetReservedGlobalVariables() {
734 unset($GLOBALS['PAGES_TYPES']);
735 unset($GLOBALS['TCA']);
736 unset($GLOBALS['TBE_MODULES']);
737 unset($GLOBALS['TBE_STYLES']);
738 unset($GLOBALS['FILEICONS']);
739 // Those set in init.php:
740 unset($GLOBALS['WEBMOUNTS']);
741 unset($GLOBALS['FILEMOUNTS']);
742 unset($GLOBALS['BE_USER']);
743 // Those set otherwise:
744 unset($GLOBALS['TBE_MODULES_EXT']);
745 unset($GLOBALS['TCA_DESCR']);
746 unset($GLOBALS['LOCAL_LANG']);
747 unset($GLOBALS['TYPO3_AJAX']);
748 return $this;
749 }
750
751 /**
752 * Initialize database connection in $GLOBALS and connect if requested
753 *
754 * @param boolean $connect Whether db should be connected
755 * @return \TYPO3\CMS\Core\Core\Bootstrap
756 * @internal This is not a public API method, do not use in own extensions
757 */
758 public function initializeTypo3DbGlobal() {
759 /** @var $databaseConnection \TYPO3\CMS\Core\Database\DatabaseConnection */
760 $databaseConnection = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
761 $databaseConnection->setDatabaseName(TYPO3_db);
762 $databaseConnection->setDatabaseUsername(TYPO3_db_username);
763 $databaseConnection->setDatabasePassword(TYPO3_db_password);
764
765 $databaseHost = TYPO3_db_host;
766 if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['port'])) {
767 $databaseConnection->setDatabasePort($GLOBALS['TYPO3_CONF_VARS']['DB']['port']);
768 } elseif (strpos($databaseHost, ':') > 0) {
769 // @TODO: Find a way to handle this case in the install tool and drop this
770 list($databaseHost, $databasePort) = explode(':', $databaseHost);
771 $databaseConnection->setDatabasePort($databasePort);
772 }
773 if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['socket'])) {
774 $databaseConnection->setDatabaseSocket($GLOBALS['TYPO3_CONF_VARS']['DB']['socket']);
775 }
776 $databaseConnection->setDatabaseHost($databaseHost);
777
778 $databaseConnection->debugOutput = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'];
779
780 if (
781 isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'])
782 && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect']
783 ) {
784 $databaseConnection->setPersistentDatabaseConnection(TRUE);
785 }
786
787 $isDatabaseHostLocalHost = $databaseHost === 'localhost' || $databaseHost === '127.0.0.1' || $databaseHost === '::1';
788 if (
789 isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['dbClientCompress'])
790 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['dbClientCompress']
791 && !$isDatabaseHostLocalHost
792 ) {
793 $databaseConnection->setConnectionCompression(TRUE);
794 }
795
796 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'])) {
797 $commandsAfterConnect = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(
798 LF,
799 str_replace('\' . LF . \'', LF, $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']),
800 TRUE
801 );
802 $databaseConnection->setInitializeCommandsAfterConnect($commandsAfterConnect);
803 }
804
805 $GLOBALS['TYPO3_DB'] = $databaseConnection;
806
807 return $this;
808 }
809
810 /**
811 * Check adminOnly configuration variable and redirects
812 * to an URL in file typo3conf/LOCK_BACKEND or exit the script
813 *
814 * @throws \RuntimeException
815 * @return Bootstrap
816 * @internal This is not a public API method, do not use in own extensions
817 */
818 public function checkLockedBackendAndRedirectOrDie() {
819 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
820 throw new \RuntimeException('TYPO3 Backend locked: Backend and Install Tool are locked for maintenance. [BE][adminOnly] is set to "' . intval($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly']) . '".', 1294586847);
821 }
822 if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
823 if (TYPO3_PROCEED_IF_NO_USER === 2) {
824
825 } else {
826 $fileContent = Utility\GeneralUtility::getUrl(PATH_typo3conf . 'LOCK_BACKEND');
827 if ($fileContent) {
828 header('Location: ' . $fileContent);
829 } else {
830 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);
831 }
832 die;
833 }
834 }
835 return $this;
836 }
837
838 /**
839 * Compare client IP with IPmaskList and exit the script run
840 * if the client is not allowed to access the backend
841 *
842 * @return Bootstrap
843 * @internal This is not a public API method, do not use in own extensions
844 */
845 public function checkBackendIpOrDie() {
846 if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
847 if (!Utility\GeneralUtility::cmpIP(Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
848 // Send Not Found header - if the webserver can make use of it
849 header('Status: 404 Not Found');
850 // Just point us away from here...
851 header('Location: http://');
852 // ... and exit good!
853 die;
854 }
855 }
856 return $this;
857 }
858
859 /**
860 * Check lockSSL configuration variable and redirect
861 * to https version of the backend if needed
862 *
863 * @return Bootstrap
864 * @internal This is not a public API method, do not use in own extensions
865 */
866 public function checkSslBackendAndRedirectIfNeeded() {
867 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'])) {
868 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort'])) {
869 $sslPortSuffix = ':' . intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort']);
870 } else {
871 $sslPortSuffix = '';
872 }
873 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] == 3) {
874 $requestStr = substr(Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT'), strlen(Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir));
875 if ($requestStr === 'index.php' && !Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
876 list(, $url) = explode('://', Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 2);
877 list($server, $address) = explode('/', $url, 2);
878 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
879 die;
880 }
881 } elseif (!Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
882 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL']) === 2) {
883 list(, $url) = explode('://', Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir, 2);
884 list($server, $address) = explode('/', $url, 2);
885 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
886 } else {
887 // Send Not Found header - if the webserver can make use of it...
888 header('Status: 404 Not Found');
889 // Just point us away from here...
890 header('Location: http://');
891 }
892 // ... and exit good!
893 die;
894 }
895 }
896 return $this;
897 }
898
899 /**
900 * Load TCA for frontend
901 *
902 * This method is *only* executed in frontend scope. The idea is to execute the
903 * whole TCA and ext_tables (which manipulate TCA) on first frontend access,
904 * and then cache the full TCA on disk to be used for the next run again.
905 *
906 * This way, ext_tables.php ist not executed every time, but $GLOBALS['TCA']
907 * is still always there.
908 *
909 * @return Bootstrap
910 * @internal This is not a public API method, do not use in own extensions
911 */
912 public function loadCachedTca() {
913 $cacheIdentifier = 'tca_fe_' . sha1((TYPO3_version . PATH_site . 'tca_fe'));
914 /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
915 $codeCache = $GLOBALS['typo3CacheManager']->getCache('cache_core');
916 if ($codeCache->has($cacheIdentifier)) {
917 // substr is necessary, because the php frontend wraps php code around the cache value
918 $GLOBALS['TCA'] = unserialize(substr($codeCache->get($cacheIdentifier), 6, -2));
919 } else {
920 $this->loadExtensionTables(TRUE);
921 $codeCache->set($cacheIdentifier, serialize($GLOBALS['TCA']));
922 }
923 return $this;
924 }
925
926 /**
927 * Load ext_tables and friends.
928 *
929 * This will mainly set up $TCA and several other global arrays
930 * through API's like extMgm.
931 * Executes ext_tables.php files of loaded extensions or the
932 * according cache file if exists.
933 *
934 * @param boolean $allowCaching True, if reading compiled ext_tables file from cache is allowed
935 * @return Bootstrap
936 * @internal This is not a public API method, do not use in own extensions
937 */
938 public function loadExtensionTables($allowCaching = TRUE) {
939 Utility\ExtensionManagementUtility::loadBaseTca($allowCaching);
940 Utility\ExtensionManagementUtility::loadExtTables($allowCaching);
941 $this->executeExtTablesAdditionalFile();
942 $this->runExtTablesPostProcessingHooks();
943 return $this;
944 }
945
946 /**
947 * Execute TYPO3_extTableDef_script if defined and exists
948 *
949 * Note: For backwards compatibility some global variables are
950 * explicitly set as global to be used without $GLOBALS[] in
951 * the extension table script. It is discouraged to access variables like
952 * $TBE_MODULES directly, but we can not prohibit
953 * this without heavily breaking backwards compatibility.
954 *
955 * @TODO : We could write a scheduler / reports module or an update checker
956 * @TODO : It should be defined, which global arrays are ok to be manipulated
957 *
958 * @return void
959 */
960 protected function executeExtTablesAdditionalFile() {
961 // It is discouraged to use those global variables directly, but we
962 // can not prohibit this without breaking backwards compatibility
963 global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
964 global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
965 global $PAGES_TYPES, $TBE_STYLES, $FILEICONS;
966 global $_EXTKEY;
967 // Load additional ext tables script if the file exists
968 $extTablesFile = PATH_typo3conf . TYPO3_extTableDef_script;
969 if (file_exists($extTablesFile) && is_file($extTablesFile)) {
970 include $extTablesFile;
971 }
972
973 // Apply TCA onto tables to be categorized
974 \TYPO3\CMS\Core\Category\CategoryRegistry::getInstance()->applyTca();
975 }
976
977 /**
978 * Check for registered ext tables hooks and run them
979 *
980 * @throws \UnexpectedValueException
981 * @return void
982 */
983 protected function runExtTablesPostProcessingHooks() {
984 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
985 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] as $classReference) {
986 /** @var $hookObject \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface */
987 $hookObject = Utility\GeneralUtility::getUserObj($classReference);
988 if (!$hookObject instanceof \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface) {
989 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\Database\\TableConfigurationPostProcessingHookInterface', 1320585902);
990 }
991 $hookObject->processData();
992 }
993 }
994 }
995
996 /**
997 * Initialize sprite manager
998 *
999 * @return Bootstrap
1000 * @internal This is not a public API method, do not use in own extensions
1001 */
1002 public function initializeSpriteManager() {
1003 \TYPO3\CMS\Backend\Sprite\SpriteManager::initialize();
1004 return $this;
1005 }
1006
1007 /**
1008 * Initialize backend user object in globals
1009 *
1010 * @return Bootstrap
1011 * @internal This is not a public API method, do not use in own extensions
1012 */
1013 public function initializeBackendUser() {
1014 /** @var $backendUser \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */
1015 $backendUser = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
1016 $backendUser->warningEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
1017 $backendUser->lockIP = $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'];
1018 $backendUser->auth_timeout_field = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']);
1019 $backendUser->OS = TYPO3_OS;
1020 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
1021 $backendUser->dontSetCookie = TRUE;
1022 }
1023 // The global must be available very early, because methods below
1024 // might trigger code which relies on it. See: #45625
1025 $GLOBALS['BE_USER'] = $backendUser;
1026 $backendUser->start();
1027 return $this;
1028 }
1029
1030 /**
1031 * Initializes and ensures authenticated access
1032 *
1033 * @internal This is not a public API method, do not use in own extensions
1034 * @return \TYPO3\CMS\Core\Core\Bootstrap
1035 */
1036 public function initializeBackendAuthentication() {
1037 $GLOBALS['BE_USER']->checkCLIuser();
1038 $GLOBALS['BE_USER']->backendCheckLogin();
1039 return $this;
1040 }
1041
1042 /**
1043 * Initialize backend user mount points
1044 *
1045 * @return Bootstrap
1046 * @internal This is not a public API method, do not use in own extensions
1047 */
1048 public function initializeBackendUserMounts() {
1049 // Includes deleted mount pages as well! @TODO: Figure out why ...
1050 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
1051 $GLOBALS['BE_USER']->getFileStorages();
1052 $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->groupData['filemounts'];
1053 return $this;
1054 }
1055
1056 /**
1057 * Initialize language object
1058 *
1059 * @return Bootstrap
1060 * @internal This is not a public API method, do not use in own extensions
1061 */
1062 public function initializeLanguageObject() {
1063 /** @var $GLOBALS['LANG'] \TYPO3\CMS\Lang\LanguageService */
1064 $GLOBALS['LANG'] = Utility\GeneralUtility::makeInstance('TYPO3\CMS\Lang\LanguageService');
1065 $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
1066 return $this;
1067 }
1068
1069 /**
1070 * Throw away all output that may have happened during bootstrapping by weird extensions
1071 *
1072 * @return Bootstrap
1073 * @internal This is not a public API method, do not use in own extensions
1074 */
1075 public function endOutputBufferingAndCleanPreviousOutput() {
1076 ob_clean();
1077 return $this;
1078 }
1079
1080 /**
1081 * Initialize output compression if configured
1082 *
1083 * @return Bootstrap
1084 * @internal This is not a public API method, do not use in own extensions
1085 */
1086 public function initializeOutputCompression() {
1087 if (extension_loaded('zlib') && $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']) {
1088 if (Utility\MathUtility::canBeInterpretedAsInteger($GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'])) {
1089 @ini_set('zlib.output_compression_level', $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']);
1090 }
1091 ob_start('ob_gzhandler');
1092 }
1093 return $this;
1094 }
1095
1096 /**
1097 * Initialize module menu object
1098 *
1099 * @return Bootstrap
1100 * @internal This is not a public API method, do not use in own extensions
1101 */
1102 public function initializeModuleMenuObject() {
1103 /** @var $moduleMenuUtility \TYPO3\CMS\Backend\Module\ModuleController */
1104 $moduleMenuUtility = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleController');
1105 $moduleMenuUtility->createModuleMenu();
1106 return $this;
1107 }
1108
1109 /**
1110 * Things that should be performed to shut down the framework.
1111 * This method is called in all important scripts for a clean
1112 * shut down of the system.
1113 *
1114 * @return Bootstrap
1115 * @internal This is not a public API method, do not use in own extensions
1116 */
1117 public function shutdown() {
1118 return $this;
1119 }
1120
1121 /**
1122 * Provides an instance of "template" for backend-modules to
1123 * work with.
1124 *
1125 * @return Bootstrap
1126 * @internal This is not a public API method, do not use in own extensions
1127 */
1128 public function initializeBackendTemplate() {
1129 $GLOBALS['TBE_TEMPLATE'] = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
1130 return $this;
1131 }
1132 }