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