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