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