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