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