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