2c7cae2bb3b765115b69450ed2de2872ebd12cca
[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 '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 * Disable direct creation of this object.
63 */
64 protected function __construct() {
65 $this->requestId = uniqid();
66 }
67
68 /**
69 * Disable direct cloning of this object.
70 */
71 protected function __clone() {
72
73 }
74
75 /**
76 * Return 'this' as singleton
77 *
78 * @return \TYPO3\CMS\Core\Core\Bootstrap
79 * @internal This is not a public API method, do not use in own extensions
80 */
81 static public function getInstance() {
82 if (is_null(self::$instance)) {
83 self::$instance = new \TYPO3\CMS\Core\Core\Bootstrap();
84 }
85 return self::$instance;
86 }
87
88 /**
89 * Gets the request's unique ID
90 *
91 * @return string Unique request ID
92 * @internal This is not a public API method, do not use in own extensions
93 */
94 public function getRequestId() {
95 return $this->requestId;
96 }
97
98 /**
99 * Prevent any unwanted output that may corrupt AJAX/compression.
100 * This does not interfere with "die()" or "echo"+"exit()" messages!
101 *
102 * @return \TYPO3\CMS\Core\Core\Bootstrap
103 * @internal This is not a public API method, do not use in own extensions
104 */
105 public function startOutputBuffering() {
106 ob_start();
107 return $this;
108 }
109
110 /**
111 * Run the base setup that checks server environment,
112 * determines pathes, populates base files and sets common configuration.
113 *
114 * Script execution will be aborted if something fails here.
115 *
116 * @param string $relativePathPart Relative path of the entry script back to document root
117 * @return \TYPO3\CMS\Core\Core\Bootstrap
118 * @internal This is not a public API method, do not use in own extensions
119 */
120 public function baseSetup($relativePathPart = '') {
121 \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::run($relativePathPart);
122 return $this;
123 }
124
125 /**
126 * Redirect to install tool if LocalConfiguration.php is missing
127 *
128 * @param string $pathUpToDocumentRoot Can contain eg. '../' if called from a sub directory
129 * @return \TYPO3\CMS\Core\Core\Bootstrap
130 * @internal This is not a public API method, do not use in own extensions
131 */
132 public function redirectToInstallToolIfLocalConfigurationFileDoesNotExist($pathUpToDocumentRoot = '') {
133 /** @var $configurationManager \TYPO3\CMS\Core\Configuration\ConfigurationManager */
134 $configurationManager = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
135 if (
136 !file_exists($configurationManager->getLocalConfigurationFileLocation())
137 && !file_exists($configurationManager->getLocalconfFileLocation())
138 ) {
139 require_once __DIR__ . '/../Utility/HttpUtility.php';
140 Utility\HttpUtility::redirect($pathUpToDocumentRoot . 'typo3/install/index.php?mode=123&step=1&password=joh316');
141 }
142 return $this;
143 }
144
145 /**
146 * Includes LocalConfiguration.php and sets several
147 * global settings depending on configuration.
148 *
149 * @return \TYPO3\CMS\Core\Core\Bootstrap
150 * @internal This is not a public API method, do not use in own extensions
151 */
152 public function loadConfigurationAndInitialize() {
153 $this->getInstance()
154 ->populateLocalConfiguration()
155 ->registerExtDirectComponents()
156 ->initializeCachingFramework()
157 ->registerAutoloader()
158 ->checkUtf8DatabaseSettingsOrDie()
159 ->transferDeprecatedCurlSettings()
160 ->setCacheHashOptions()
161 ->enforceCorrectProxyAuthScheme()
162 ->setDefaultTimezone()
163 ->initializeL10nLocales()
164 ->configureImageProcessingOptions()
165 ->convertPageNotFoundHandlingToBoolean()
166 ->registerGlobalDebugFunctions()
167 ->registerSwiftMailer()
168 ->configureExceptionHandling()
169 ->setMemoryLimit()
170 ->defineTypo3RequestTypes();
171 return $this;
172 }
173
174 /**
175 * Load TYPO3_LOADED_EXT and ext_localconf
176 *
177 * @param boolean $allowCaching
178 * @return \TYPO3\CMS\Core\Core\Bootstrap
179 * @internal This is not a public API method, do not use in own extensions
180 */
181 public function loadTypo3LoadedExtAndExtLocalconf($allowCaching = TRUE) {
182 $this->getInstance()
183 ->populateTypo3LoadedExtGlobal($allowCaching)
184 ->loadAdditionalConfigurationFromExtensions($allowCaching);
185 return $this;
186 }
187
188 /**
189 * Load TYPO3_LOADED_EXT, recreate class loader registry and load ext_localconf
190 *
191 * @param boolean $allowCaching
192 * @return \TYPO3\CMS\Core\Core\Bootstrap
193 * @internal This is not a public API method, do not use in own extensions
194 */
195 public function reloadTypo3LoadedExtAndClassLoaderAndExtLocalconf() {
196 $bootstrap = $this->getInstance();
197 $bootstrap->populateTypo3LoadedExtGlobal(FALSE);
198 \TYPO3\CMS\Core\Core\ClassLoader::loadClassLoaderCache();
199 $bootstrap->loadAdditionalConfigurationFromExtensions(FALSE);
200 return $this;
201 }
202
203 /**
204 * Sets up additional configuration applied in all scopes
205 *
206 * @return \TYPO3\CMS\Core\Core\Bootstrap
207 * @internal This is not a public API method, do not use in own extensions
208 */
209 public function applyAdditionalConfigurationSettings() {
210 $this->getInstance()
211 ->deprecationLogForOldExtCacheSetting()
212 ->initializeExceptionHandling()
213 ->setFinalCachingFrameworkCacheConfiguration()
214 ->defineLoggingAndExceptionConstants()
215 ->unsetReservedGlobalVariables();
216 return $this;
217 }
218
219 /**
220 * Throws an exception if no browser could be identified
221 *
222 * @return \TYPO3\CMS\Core\Core\Bootstrap
223 * @throws \RuntimeException
224 * @internal This is not a public API method, do not use in own extensions
225 */
226 public function checkValidBrowserOrDie() {
227 // Checks for proper browser
228 if (empty($GLOBALS['CLIENT']['BROWSER'])) {
229 throw new \RuntimeException('Browser Error: Your browser version looks incompatible with this TYPO3 version!', 1294587023);
230 }
231 return $this;
232 }
233
234 /**
235 * Populate the local configuration.
236 * Merge default TYPO3_CONF_VARS with content of typo3conf/LocalConfiguration.php,
237 * execute typo3conf/AdditionalConfiguration.php, define database related constants.
238 *
239 * @return \TYPO3\CMS\Core\Core\Bootstrap
240 */
241 protected function populateLocalConfiguration() {
242 try {
243 Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager')
244 ->exportConfiguration();
245 } catch (\Exception $e) {
246 die($e->getMessage());
247 }
248 define('TYPO3_db', $GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
249 define('TYPO3_db_username', $GLOBALS['TYPO3_CONF_VARS']['DB']['username']);
250 define('TYPO3_db_password', $GLOBALS['TYPO3_CONF_VARS']['DB']['password']);
251 define('TYPO3_db_host', $GLOBALS['TYPO3_CONF_VARS']['DB']['host']);
252 define('TYPO3_extTableDef_script',
253 isset($GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript'])
254 ? $GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript']
255 : 'extTables.php');
256 unset($GLOBALS['TYPO3_CONF_VARS']['DB']);
257 define('TYPO3_user_agent', 'User-Agent: ' . $GLOBALS['TYPO3_CONF_VARS']['HTTP']['userAgent']);
258 return $this;
259 }
260
261 /**
262 * Register default ExtDirect components
263 *
264 * @return \TYPO3\CMS\Core\Core\Bootstrap
265 */
266 protected function registerExtDirectComponents() {
267 if (TYPO3_MODE === 'BE') {
268 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.DataProvider', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeDataProvider', 'web', 'user,group');
269 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.Commands', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeCommands', 'web', 'user,group');
270 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.ContextMenuDataProvider', 'TYPO3\\CMS\\Backend\\ContextMenu\\Pagetree\\Extdirect\\ContextMenuConfiguration', 'web', 'user,group');
271 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.LiveSearchActions.ExtDirect', 'TYPO3\\CMS\\Backend\\Search\\LiveSearch\\ExtDirect\\LiveSearchDataProvider', 'web_list', 'user,group');
272 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.BackendUserSettings.ExtDirect', 'TYPO3\\CMS\\Backend\\User\\ExtDirect\\BackendUserSettingsDataProvider');
273 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.CSH.ExtDirect', 'TYPO3\\CMS\\ContextHelp\\ExtDirect\\ContextHelpDataProvider');
274 Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.ExtDirectStateProvider.ExtDirect', 'TYPO3\\CMS\\Backend\\InterfaceState\\ExtDirect\\DataProvider');
275 Utility\ExtensionManagementUtility::registerExtDirectComponent(
276 'TYPO3.Components.DragAndDrop.CommandController',
277 Utility\ExtensionManagementUtility::extPath('backend') . 'Classes/View/PageLayout/Extdirect/ExtdirectPageCommands.php:TYPO3\\CMS\\Backend\\View\\PageLayout\\ExtDirect\\ExtdirectPageCommands', 'web', 'user,group'
278 );
279 }
280 return $this;
281 }
282
283 /**
284 * Initialize caching framework
285 *
286 * @return \TYPO3\CMS\Core\Core\Bootstrap
287 */
288 protected function initializeCachingFramework() {
289 \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework();
290 return $this;
291 }
292
293 /**
294 * Register autoloader
295 *
296 * @return \TYPO3\CMS\Core\Core\Bootstrap
297 */
298 protected function registerAutoloader() {
299 if (PHP_VERSION_ID < 50307) {
300 \TYPO3\CMS\Core\Compatibility\CompatbilityClassLoaderPhpBelow50307::registerAutoloader();
301 } else {
302 \TYPO3\CMS\Core\Core\ClassLoader::registerAutoloader();
303 }
304 return $this;
305 }
306
307 /**
308 * Checking for UTF-8 in the settings since TYPO3 4.5
309 *
310 * Since TYPO3 4.5, everything other than UTF-8 is deprecated.
311 *
312 * [BE][forceCharset] is set to the charset that TYPO3 is using
313 * [SYS][setDBinit] is used to set the DB connection
314 * and both settings need to be adjusted for UTF-8 in order to work properly
315 *
316 * @return \TYPO3\CMS\Core\Core\Bootstrap
317 */
318 protected function checkUtf8DatabaseSettingsOrDie() {
319 // Check if [BE][forceCharset] has been set in localconf.php
320 if (isset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'])) {
321 // die() unless we're already on UTF-8
322 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] != 'utf-8' &&
323 $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] &&
324 TYPO3_enterInstallScript !== '1') {
325
326 die('This installation was just upgraded to a new TYPO3 version. Since TYPO3 4.7, utf-8 is always enforced.<br />' .
327 'The configuration option $GLOBALS[\'TYPO3_CONF_VARS\'][BE][forceCharset] was marked as deprecated in TYPO3 4.5 and is now ignored.<br />' .
328 'You have configured the value to something different, which is not supported anymore.<br />' .
329 'Please proceed to the Update Wizard in the TYPO3 Install Tool to update your configuration.'
330 );
331 } else {
332 unset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
333 }
334 }
335
336 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']) &&
337 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] !== '-1' &&
338 preg_match('/SET NAMES [\'"]?utf8[\'"]?/i', $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']) === FALSE &&
339 TYPO3_enterInstallScript !== '1') {
340
341 // Only accept "SET NAMES utf8" for this setting, otherwise die with a nice error
342 die('This TYPO3 installation is using the $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'setDBinit\'] property with the following value:' . chr(10) .
343 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] . chr(10) . chr(10) .
344 'It looks like UTF-8 is not used for this connection.' . chr(10) . chr(10) .
345 'Everything other than UTF-8 is unsupported since TYPO3 4.7.' . chr(10) .
346 'The DB, its connection and TYPO3 should be migrated to UTF-8 therefore. Please check your setup.'
347 );
348 } else {
349 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] = 'SET NAMES utf8;';
350 }
351 return $this;
352 }
353
354 /**
355 * Parse old curl options and set new http ones instead
356 *
357 * @TODO : This code segment must still be finished
358 * @return \TYPO3\CMS\Core\Core\Bootstrap
359 */
360 protected function transferDeprecatedCurlSettings() {
361 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'])) {
362 $proxyParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'], 2);
363 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = $proxyParts[0];
364 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port'] = $proxyParts[1];
365 }
366 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'])) {
367 $userPassParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'], 2);
368 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'] = $userPassParts[0];
369 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_password'] = $userPassParts[1];
370 }
371 return $this;
372 }
373
374 /**
375 * Set cacheHash options
376 *
377 * @return \TYPO3\CMS\Core\Core\Bootstrap
378 */
379 protected function setCacheHashOptions() {
380 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] = array(
381 'cachedParametersWhiteList' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashOnlyForParameters'], TRUE),
382 'excludedParameters' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'], TRUE),
383 'requireCacheHashPresenceParameters' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashRequiredParameters'], TRUE)
384 );
385 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty']) === '*') {
386 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludeAllEmptyParameters'] = TRUE;
387 } else {
388 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParametersIfEmpty'] = Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty'], TRUE);
389 }
390 return $this;
391 }
392
393 /**
394 * $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] must be either
395 * 'digest' or 'basic' with fallback to 'basic'
396 *
397 * @return \TYPO3\CMS\Core\Core\Bootstrap
398 */
399 protected function enforceCorrectProxyAuthScheme() {
400 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] === 'digest' ?: ($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] = 'basic');
401 return $this;
402 }
403
404 /**
405 * Set default timezone
406 *
407 * @return \TYPO3\CMS\Core\Core\Bootstrap
408 */
409 protected function setDefaultTimezone() {
410 $timeZone = $GLOBALS['TYPO3_CONF_VARS']['SYS']['phpTimeZone'];
411 if (empty($timeZone)) {
412 // Time zone from the server environment (TZ env or OS query)
413 $defaultTimeZone = @date_default_timezone_get();
414 if ($defaultTimeZone !== '') {
415 $timeZone = $defaultTimeZone;
416 } else {
417 $timeZone = 'UTC';
418 }
419 }
420 // Set default to avoid E_WARNINGs with PHP > 5.3
421 date_default_timezone_set($timeZone);
422 return $this;
423 }
424
425 /**
426 * Initialize the locales handled by TYPO3
427 *
428 * @return \TYPO3\CMS\Core\Core\Bootstrap
429 */
430 protected function initializeL10nLocales() {
431 \TYPO3\CMS\Core\Localization\Locales::initialize();
432 return $this;
433 }
434
435 /**
436 * Based on the configuration of the image processing some options are forced
437 * to simplify configuration settings and combinations
438 *
439 * @return \TYPO3\CMS\Core\Core\Bootstrap
440 */
441 protected function configureImageProcessingOptions() {
442 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['image_processing']) {
443 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] = 0;
444 $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'] = 0;
445 }
446 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
447 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'] = '';
448 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] = '';
449 $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] = 'gif,jpg,jpeg,png';
450 $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] = 0;
451 }
452 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']) {
453 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 1;
454 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_no_effects'] = 1;
455 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif'] = 1;
456 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] === 'gm') {
457 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 0;
458 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState'] = 0;
459 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_no_effects'] = 1;
460 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_v5effects'] = -1;
461 }
462 }
463 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState']) {
464 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ? 0 : 1;
465 }
466 return $this;
467 }
468
469 /**
470 * Convert type of "pageNotFound_handling" setting in case it was written as a
471 * string (e.g. if edited in Install Tool)
472 *
473 * @TODO : Remove, if the Install Tool handles such data types correctly
474 * @return \TYPO3\CMS\Core\Core\Bootstrap
475 */
476 protected function convertPageNotFoundHandlingToBoolean() {
477 if (!strcasecmp($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'], 'TRUE')) {
478 $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = TRUE;
479 }
480 return $this;
481 }
482
483 /**
484 * Register xdebug(), debug(), debugBegin() and debugEnd() as global functions
485 *
486 * Note: Yes, this is possible in php! xdebug() is then a global function, even
487 * if registerGlobalDebugFunctions() is encapsulated in class scope.
488 *
489 * @return \TYPO3\CMS\Core\Core\Bootstrap
490 */
491 protected function registerGlobalDebugFunctions() {
492 require_once('GlobalDebugFunctions.php');
493 return $this;
494 }
495
496 /**
497 * Mail sending via Swift Mailer
498 *
499 * @return \TYPO3\CMS\Core\Core\Bootstrap
500 */
501 protected function registerSwiftMailer() {
502 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'][] =
503 'TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter';
504 return $this;
505 }
506
507 /**
508 * Configure and set up exception and error handling
509 *
510 * @return \TYPO3\CMS\Core\Core\Bootstrap
511 */
512 protected function configureExceptionHandling() {
513 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
514 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'];
515 // Turn error logging on/off.
516 if (($displayErrors = intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'])) != '-1') {
517 // Special value "2" enables this feature only if $GLOBALS['TYPO3_CONF_VARS'][SYS][devIPmask] matches
518 if ($displayErrors == 2) {
519 if (Utility\GeneralUtility::cmpIP(Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
520 $displayErrors = 1;
521 } else {
522 $displayErrors = 0;
523 }
524 }
525 if ($displayErrors == 0) {
526 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = 0;
527 }
528 if ($displayErrors == 1) {
529 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
530 define('TYPO3_ERRORHANDLER_MODE', 'debug');
531 }
532 @ini_set('display_errors', $displayErrors);
533 } elseif (Utility\GeneralUtility::cmpIP(Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
534 // With displayErrors = -1 (default), turn on debugging if devIPmask matches:
535 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
536 }
537 return $this;
538 }
539
540 /**
541 * Set PHP memory limit depending on value of
542 * $GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']
543 *
544 * @return \TYPO3\CMS\Core\Core\Bootstrap
545 */
546 protected function setMemoryLimit() {
547 if (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) > 16) {
548 @ini_set('memory_limit', (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) . 'm'));
549 }
550 return $this;
551 }
552
553 /**
554 * Define TYPO3_REQUESTTYPE* constants
555 * so devs exactly know what type of request it is
556 *
557 * @return \TYPO3\CMS\Core\Core\Bootstrap
558 */
559 protected function defineTypo3RequestTypes() {
560 define('TYPO3_REQUESTTYPE_FE', 1);
561 define('TYPO3_REQUESTTYPE_BE', 2);
562 define('TYPO3_REQUESTTYPE_CLI', 4);
563 define('TYPO3_REQUESTTYPE_AJAX', 8);
564 define('TYPO3_REQUESTTYPE_INSTALL', 16);
565 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));
566 return $this;
567 }
568
569 /**
570 * Set up $GLOBALS['TYPO3_LOADED_EXT'] array with basic information
571 * about extensions.
572 *
573 * @param boolean $allowCaching
574 * @return \TYPO3\CMS\Core\Core\Bootstrap
575 */
576 protected function populateTypo3LoadedExtGlobal($allowCaching = TRUE) {
577 $GLOBALS['TYPO3_LOADED_EXT'] = Utility\ExtensionManagementUtility::loadTypo3LoadedExtensionInformation($allowCaching);
578 return $this;
579 }
580
581 /**
582 * Load extension configuration files (ext_localconf.php)
583 *
584 * The ext_localconf.php files in extensions are meant to make changes
585 * to the global $TYPO3_CONF_VARS configuration array.
586 *
587 * @param boolean $allowCaching
588 * @return \TYPO3\CMS\Core\Core\Bootstrap
589 */
590 protected function loadAdditionalConfigurationFromExtensions($allowCaching = TRUE) {
591 Utility\ExtensionManagementUtility::loadExtLocalconf($allowCaching);
592 return $this;
593 }
594
595 /**
596 * Write deprecation log if deprecated extCache setting was set in the instance.
597 *
598 * @return \TYPO3\CMS\Core\Core\Bootstrap
599 * @deprecated since 6.0, the check will be removed two version later.
600 */
601 protected function deprecationLogForOldExtCacheSetting() {
602 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && $GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] !== -1) {
603 Utility\GeneralUtility::deprecationLog('Setting $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'extCache\'] is unused and can be removed from localconf.php');
604 }
605 return $this;
606 }
607
608 /**
609 * Initialize exception handling
610 *
611 * @return \TYPO3\CMS\Core\Core\Bootstrap
612 */
613 protected function initializeExceptionHandling() {
614 if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] !== '') {
615 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'] !== '') {
616 // Register an error handler for the given errorHandlerErrors
617 $errorHandler = Utility\GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors']);
618 // Set errors which will be converted in an exception
619 $errorHandler->setExceptionalErrors($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors']);
620 }
621 // Instantiate the exception handler once to make sure object is registered
622 // @TODO: Figure out if this is really needed
623 Utility\GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler']);
624 }
625 return $this;
626 }
627
628 /**
629 * Extensions may register new caches, so we set the
630 * global cache array to the manager again at this point
631 *
632 * @return \TYPO3\CMS\Core\Core\Bootstrap
633 */
634 protected function setFinalCachingFrameworkCacheConfiguration() {
635 $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
636 return $this;
637 }
638
639 /**
640 * Define logging and exception constants
641 *
642 * @return \TYPO3\CMS\Core\Core\Bootstrap
643 */
644 protected function defineLoggingAndExceptionConstants() {
645 define('TYPO3_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']);
646 define('TYPO3_ERROR_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG']);
647 define('TYPO3_EXCEPTION_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG']);
648 return $this;
649 }
650
651 /**
652 * Unsetting reserved global variables:
653 * Those are set in "ext:core/ext_tables.php" file:
654 *
655 * @return \TYPO3\CMS\Core\Core\Bootstrap
656 */
657 protected function unsetReservedGlobalVariables() {
658 unset($GLOBALS['PAGES_TYPES']);
659 unset($GLOBALS['TCA']);
660 unset($GLOBALS['TBE_MODULES']);
661 unset($GLOBALS['TBE_STYLES']);
662 unset($GLOBALS['FILEICONS']);
663 // Those set in init.php:
664 unset($GLOBALS['WEBMOUNTS']);
665 unset($GLOBALS['FILEMOUNTS']);
666 unset($GLOBALS['BE_USER']);
667 // Those set otherwise:
668 unset($GLOBALS['TBE_MODULES_EXT']);
669 unset($GLOBALS['TCA_DESCR']);
670 unset($GLOBALS['LOCAL_LANG']);
671 unset($GLOBALS['TYPO3_AJAX']);
672 return $this;
673 }
674
675 /**
676 * Initialize database connection in $GLOBALS and connect if requested
677 *
678 * @param boolean $connect Whether db should be connected
679 * @return \TYPO3\CMS\Core\Core\Bootstrap
680 * @internal This is not a public API method, do not use in own extensions
681 */
682 public function initializeTypo3DbGlobal() {
683 /** @var $databaseConnection \TYPO3\CMS\Core\Database\DatabaseConnection */
684 $databaseConnection = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
685 $databaseConnection->setDatabaseName(TYPO3_db);
686 $databaseConnection->setDatabaseUsername(TYPO3_db_username);
687 $databaseConnection->setDatabasePassword(TYPO3_db_password);
688
689 $databaseHost = TYPO3_db_host;
690 // Check if a port was specified
691 if (strpos($databaseHost, ':') > 0) {
692 list($databaseHost, $databasePort) = explode(':', $databaseHost);
693 $databaseConnection->setDatabasePort($databasePort);
694 }
695 $databaseConnection->setDatabaseHost($databaseHost);
696
697 $databaseConnection->debugOutput = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'];
698
699 if (
700 isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'])
701 && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect']
702 ) {
703 $databaseConnection->setPersistentDatabaseConnection(TRUE);
704 }
705
706 $isDatabaseHostLocalHost = $databaseHost === 'localhost' || $databaseHost === '127.0.0.1' || $databaseHost === '::1';
707 if (
708 isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['dbClientCompress'])
709 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['dbClientCompress']
710 && !$isDatabaseHostLocalHost
711 ) {
712 $databaseConnection->setConnectionCompression(TRUE);
713 }
714
715 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'])) {
716 $commandsAfterConnect = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(
717 LF,
718 str_replace('\' . LF . \'', LF, $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']),
719 TRUE
720 );
721 $databaseConnection->setInitializeCommandsAfterConnect($commandsAfterConnect);
722 }
723
724 $GLOBALS['TYPO3_DB'] = $databaseConnection;
725
726 return $this;
727 }
728
729 /**
730 * Check adminOnly configuration variable and redirects
731 * to an URL in file typo3conf/LOCK_BACKEND or exit the script
732 *
733 * @throws \RuntimeException
734 * @return \TYPO3\CMS\Core\Core\Bootstrap
735 * @internal This is not a public API method, do not use in own extensions
736 */
737 public function checkLockedBackendAndRedirectOrDie() {
738 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
739 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);
740 }
741 if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
742 if (TYPO3_PROCEED_IF_NO_USER === 2) {
743
744 } else {
745 $fileContent = Utility\GeneralUtility::getUrl(PATH_typo3conf . 'LOCK_BACKEND');
746 if ($fileContent) {
747 header('Location: ' . $fileContent);
748 } else {
749 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);
750 }
751 die;
752 }
753 }
754 return $this;
755 }
756
757 /**
758 * Compare client IP with IPmaskList and exit the script run
759 * if the client is not allowed to access the backend
760 *
761 * @return \TYPO3\CMS\Core\Core\Bootstrap
762 * @internal This is not a public API method, do not use in own extensions
763 */
764 public function checkBackendIpOrDie() {
765 if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
766 if (!Utility\GeneralUtility::cmpIP(Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
767 // Send Not Found header - if the webserver can make use of it
768 header('Status: 404 Not Found');
769 // Just point us away from here...
770 header('Location: http://');
771 // ... and exit good!
772 die;
773 }
774 }
775 return $this;
776 }
777
778 /**
779 * Check lockSSL configuration variable and redirect
780 * to https version of the backend if needed
781 *
782 * @return \TYPO3\CMS\Core\Core\Bootstrap
783 * @internal This is not a public API method, do not use in own extensions
784 */
785 public function checkSslBackendAndRedirectIfNeeded() {
786 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'])) {
787 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort'])) {
788 $sslPortSuffix = ':' . intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort']);
789 } else {
790 $sslPortSuffix = '';
791 }
792 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] == 3) {
793 $requestStr = substr(Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT'), strlen(Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir));
794 if ($requestStr === 'index.php' && !Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
795 list(, $url) = explode('://', Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 2);
796 list($server, $address) = explode('/', $url, 2);
797 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
798 die;
799 }
800 } elseif (!Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
801 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL']) === 2) {
802 list(, $url) = explode('://', Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir, 2);
803 list($server, $address) = explode('/', $url, 2);
804 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
805 } else {
806 // Send Not Found header - if the webserver can make use of it...
807 header('Status: 404 Not Found');
808 // Just point us away from here...
809 header('Location: http://');
810 }
811 // ... and exit good!
812 die;
813 }
814 }
815 return $this;
816 }
817
818 /**
819 * Load TCA for frontend
820 *
821 * This method is *only* executed in frontend scope. The idea is to execute the
822 * whole TCA and ext_tables (which manipulate TCA) on first frontend access,
823 * and then cache the full TCA on disk to be used for the next run again.
824 *
825 * This way, ext_tables.php ist not executed every time, but $GLOBALS['TCA']
826 * is still always there.
827 *
828 * @return \TYPO3\CMS\Core\Core\Bootstrap
829 * @internal This is not a public API method, do not use in own extensions
830 */
831 public function loadCachedTca() {
832 $cacheIdentifier = 'tca_fe_' . sha1((TYPO3_version . PATH_site . 'tca_fe'));
833 /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
834 $codeCache = $GLOBALS['typo3CacheManager']->getCache('cache_core');
835 if ($codeCache->has($cacheIdentifier)) {
836 $codeCache->requireOnce($cacheIdentifier);
837 } else {
838 $this->loadExtensionTables(TRUE);
839 $phpCodeToCache = '$GLOBALS[\'TCA\'] = ';
840 $phpCodeToCache .= Utility\ArrayUtility::arrayExport($GLOBALS['TCA']);
841 $phpCodeToCache .= ';';
842 $codeCache->set($cacheIdentifier, $phpCodeToCache);
843 }
844 return $this;
845 }
846
847 /**
848 * Load ext_tables and friends.
849 *
850 * This will mainly set up $TCA and several other global arrays
851 * through API's like extMgm.
852 * Executes ext_tables.php files of loaded extensions or the
853 * according cache file if exists.
854 *
855 * @param boolean $allowCaching True, if reading compiled ext_tables file from cache is allowed
856 * @return \TYPO3\CMS\Core\Core\Bootstrap
857 * @internal This is not a public API method, do not use in own extensions
858 */
859 public function loadExtensionTables($allowCaching = TRUE) {
860 Utility\ExtensionManagementUtility::loadBaseTca($allowCaching);
861 Utility\ExtensionManagementUtility::loadExtTables($allowCaching);
862 $this->executeExtTablesAdditionalFile();
863 $this->runExtTablesPostProcessingHooks();
864 return $this;
865 }
866
867 /**
868 * Execute TYPO3_extTableDef_script if defined and exists
869 *
870 * Note: For backwards compatibility some global variables are
871 * explicitly set as global to be used without $GLOBALS[] in
872 * the extension table script. It is discouraged to access variables like
873 * $TBE_MODULES directly, but we can not prohibit
874 * this without heavily breaking backwards compatibility.
875 *
876 * @TODO : We could write a scheduler / reports module or an update checker
877 * @TODO : It should be defined, which global arrays are ok to be manipulated
878 *
879 * @return void
880 */
881 protected function executeExtTablesAdditionalFile() {
882 // It is discouraged to use those global variables directly, but we
883 // can not prohibit this without breaking backwards compatibility
884 global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
885 global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
886 global $PAGES_TYPES, $TBE_STYLES, $FILEICONS;
887 global $_EXTKEY;
888 // Load additional ext tables script if the file exists
889 $extTablesFile = PATH_typo3conf . TYPO3_extTableDef_script;
890 if (file_exists($extTablesFile) && is_file($extTablesFile)) {
891 include $extTablesFile;
892 }
893 }
894
895 /**
896 * Check for registered ext tables hooks and run them
897 *
898 * @throws \UnexpectedValueException
899 * @return void
900 */
901 protected function runExtTablesPostProcessingHooks() {
902 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
903 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] as $classReference) {
904 /** @var $hookObject \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface */
905 $hookObject = Utility\GeneralUtility::getUserObj($classReference);
906 if (!$hookObject instanceof \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface) {
907 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\Database\\TableConfigurationPostProcessingHookInterface', 1320585902);
908 }
909 $hookObject->processData();
910 }
911 }
912 }
913
914 /**
915 * Initialize sprite manager
916 *
917 * @return \TYPO3\CMS\Core\Core\Bootstrap
918 * @internal This is not a public API method, do not use in own extensions
919 */
920 public function initializeSpriteManager() {
921 \TYPO3\CMS\Backend\Sprite\SpriteManager::initialize();
922 return $this;
923 }
924
925 /**
926 * Initialize backend user object in globals
927 *
928 * @return \TYPO3\CMS\Core\Core\Bootstrap
929 * @internal This is not a public API method, do not use in own extensions
930 */
931 public function initializeBackendUser() {
932 /** @var $backendUser \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */
933 $backendUser = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
934 $backendUser->warningEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
935 $backendUser->lockIP = $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'];
936 $backendUser->auth_timeout_field = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']);
937 $backendUser->OS = TYPO3_OS;
938 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
939 $backendUser->dontSetCookie = TRUE;
940 }
941 // The global must be available very early, because methods below
942 // might trigger code which relies on it. See: #45625
943 $GLOBALS['BE_USER'] = $backendUser;
944 $backendUser->start();
945 $backendUser->checkCLIuser();
946 $backendUser->backendCheckLogin();
947 return $this;
948 }
949
950 /**
951 * Initialize backend user mount points
952 *
953 * @return \TYPO3\CMS\Core\Core\Bootstrap
954 * @internal This is not a public API method, do not use in own extensions
955 */
956 public function initializeBackendUserMounts() {
957 // Includes deleted mount pages as well! @TODO: Figure out why ...
958 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
959 $GLOBALS['BE_USER']->getFileStorages();
960 $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->groupData['filemounts'];
961 return $this;
962 }
963
964 /**
965 * Initialize language object
966 *
967 * @return \TYPO3\CMS\Core\Core\Bootstrap
968 * @internal This is not a public API method, do not use in own extensions
969 */
970 public function initializeLanguageObject() {
971 /** @var $GLOBALS['LANG'] \TYPO3\CMS\Lang\LanguageService */
972 $GLOBALS['LANG'] = Utility\GeneralUtility::makeInstance('TYPO3\CMS\Lang\LanguageService');
973 $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
974 return $this;
975 }
976
977 /**
978 * Throw away all output that may have happened during bootstrapping by weird extensions
979 *
980 * @return \TYPO3\CMS\Core\Core\Bootstrap
981 * @internal This is not a public API method, do not use in own extensions
982 */
983 public function endOutputBufferingAndCleanPreviousOutput() {
984 ob_clean();
985 return $this;
986 }
987
988 /**
989 * Initialize output compression if configured
990 *
991 * @return \TYPO3\CMS\Core\Core\Bootstrap
992 * @internal This is not a public API method, do not use in own extensions
993 */
994 public function initializeOutputCompression() {
995 if (extension_loaded('zlib') && $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']) {
996 if (Utility\MathUtility::canBeInterpretedAsInteger($GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'])) {
997 @ini_set('zlib.output_compression_level', $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']);
998 }
999 ob_start('ob_gzhandler');
1000 }
1001 return $this;
1002 }
1003
1004 /**
1005 * Initialize module menu object
1006 *
1007 * @return \TYPO3\CMS\Core\Core\Bootstrap
1008 * @internal This is not a public API method, do not use in own extensions
1009 */
1010 public function initializeModuleMenuObject() {
1011 /** @var $moduleMenuUtility \TYPO3\CMS\Backend\Module\ModuleController */
1012 $moduleMenuUtility = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleController');
1013 $moduleMenuUtility->createModuleMenu();
1014 return $this;
1015 }
1016
1017 /**
1018 * Things that should be performed to shut down the framework.
1019 * This method is called in all important scripts for a clean
1020 * shut down of the system.
1021 *
1022 * @return \TYPO3\CMS\Core\Core\Bootstrap
1023 * @internal This is not a public API method, do not use in own extensions
1024 */
1025 public function shutdown() {
1026 if (PHP_VERSION_ID < 50307) {
1027 \TYPO3\CMS\Core\Compatibility\CompatbilityClassLoaderPhpBelow50307::unregisterAutoloader();
1028 } else {
1029 \TYPO3\CMS\Core\Core\ClassLoader::unregisterAutoloader();
1030 }
1031 return $this;
1032 }
1033
1034 /**
1035 * Provides an instance of "template" for backend-modules to
1036 * work with.
1037 *
1038 * @return \TYPO3\CMS\Core\Core\Bootstrap
1039 * @internal This is not a public API method, do not use in own extensions
1040 */
1041 public function initializeBackendTemplate() {
1042 $GLOBALS['TBE_TEMPLATE'] = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
1043 return $this;
1044 }
1045
1046 }
1047
1048
1049 ?>