2 namespace TYPO3\CMS\Core\Core
;
4 require 'SystemEnvironmentBuilder.php';
7 * This class encapsulates bootstrap related methods.
8 * It is required directly as the very first thing in entry scripts and
9 * used to define all base things like constants and pathes and so on.
11 * Most methods in this class have dependencies to each other. They can
12 * not be called in arbitrary order. The methods are ordered top down, so
13 * a method at the beginning has lower dependencies than a method further
14 * down. Do not fiddle with the load order in own scripts except you know
15 * exactly what you are doing!
17 * @author Christian Kuhn <lolli@schwarzbu.ch>
24 * @var \TYPO3\CMS\Core\Core\Bootstrap
26 static protected $instance = NULL;
36 * Disable direct creation of this object.
38 protected function __construct() {
39 $this->requestId
= uniqid();
43 * Disable direct cloning of this object.
45 protected function __clone() {
50 * Return 'this' as singleton
52 * @return \TYPO3\CMS\Core\Core\Bootstrap
54 static public function getInstance() {
55 if (is_null(self
::$instance)) {
56 self
::$instance = new \TYPO3\CMS\Core\Core\
Bootstrap();
58 return self
::$instance;
62 * Gets the request's unique ID
64 * @return string Unique request ID
66 public function getRequestId() {
67 return $this->requestId
;
71 * Prevent any unwanted output that may corrupt AJAX/compression.
72 * This does not interfere with "die()" or "echo"+"exit()" messages!
74 * @return \TYPO3\CMS\Core\Core\Bootstrap
76 public function startOutputBuffering() {
82 * Run the base setup that checks server environment,
83 * determines pathes, populates base files and sets common configuration.
85 * Script execution will be aborted if something fails here.
87 * @param string $relativePathPart Relative path of the entry script back to document root
88 * @return \TYPO3\CMS\Core\Core\Bootstrap
90 public function baseSetup($relativePathPart = '') {
91 \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
::run($relativePathPart);
96 * Throws an exception if no browser could be identified
98 * @return \TYPO3\CMS\Core\Core\Bootstrap
99 * @throws \RuntimeException
101 public function checkValidBrowserOrDie() {
102 // Checks for proper browser
103 if (empty($GLOBALS['CLIENT']['BROWSER'])) {
104 throw new \
RuntimeException('Browser Error: Your browser version looks incompatible with this TYPO3 version!', 1294587023);
110 * Register default ExtDirect components
112 * @return \TYPO3\CMS\Core\Core\Bootstrap
114 public function registerExtDirectComponents() {
115 if (TYPO3_MODE
=== 'BE') {
116 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::registerExtDirectComponent('TYPO3.Components.PageTree.DataProvider', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeDataProvider', 'web', 'user,group');
117 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::registerExtDirectComponent('TYPO3.Components.PageTree.Commands', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeCommands', 'web', 'user,group');
118 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::registerExtDirectComponent('TYPO3.Components.PageTree.ContextMenuDataProvider', 'TYPO3\\CMS\\Backend\\ContextMenu\\Pagetree\\Extdirect\\ContextMenuConfiguration', 'web', 'user,group');
119 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::registerExtDirectComponent('TYPO3.LiveSearchActions.ExtDirect', 'TYPO3\\CMS\\Backend\\Search\\LiveSearch\\ExtDirect\\LiveSearchDataProvider', 'web_list', 'user,group');
120 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::registerExtDirectComponent('TYPO3.BackendUserSettings.ExtDirect', 'TYPO3\\CMS\\Backend\\User\\ExtDirect\\BackendUserSettingsDataProvider');
121 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::registerExtDirectComponent('TYPO3.CSH.ExtDirect', 'TYPO3\\CMS\\ContextHelp\\ExtDirect\\ContextHelpDataProvider');
122 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::registerExtDirectComponent('TYPO3.ExtDirectStateProvider.ExtDirect', 'TYPO3\\CMS\\Backend\\InterfaceState\\ExtDirect\\DataProvider');
123 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::registerExtDirectComponent('TYPO3.Components.DragAndDrop.CommandController',
124 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::extPath('backend') . 'Classes/View/PageLayout/Extdirect/ExtdirectPageCommands.php:TYPO3\\CMS\\Backend\\View\\PageLayout\\ExtDirect\\ExtdirectPageCommands', 'web', 'user,group');
130 * Populate the local configuration.
131 * Merge default TYPO3_CONF_VARS with content of typo3conf/LocalConfiguration.php,
132 * execute typo3conf/AdditionalConfiguration.php, define database related constants.
134 * @return \TYPO3\CMS\Core\Core\Bootstrap
136 public function populateLocalConfiguration() {
138 \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager')->exportConfiguration();
139 } catch (\Exception
$e) {
140 die($e->getMessage());
142 define('TYPO3_db', $GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
143 define('TYPO3_db_username', $GLOBALS['TYPO3_CONF_VARS']['DB']['username']);
144 define('TYPO3_db_password', $GLOBALS['TYPO3_CONF_VARS']['DB']['password']);
145 define('TYPO3_db_host', $GLOBALS['TYPO3_CONF_VARS']['DB']['host']);
146 define('TYPO3_extTableDef_script', $GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript']);
147 unset($GLOBALS['TYPO3_CONF_VARS']['DB']);
148 define('TYPO3_user_agent', 'User-Agent: ' . $GLOBALS['TYPO3_CONF_VARS']['HTTP']['userAgent']);
153 * Redirect to install tool if database host and database are not defined
155 * @return \TYPO3\CMS\Core\Core\Bootstrap
157 public function redirectToInstallToolIfDatabaseCredentialsAreMissing() {
158 if (!TYPO3_db_host
&& !TYPO3_db
) {
159 \TYPO3\CMS\Core\Utility\HttpUtility
::redirect('install/index.php?mode=123&step=1&password=joh316');
165 * Initialize caching framework
167 * @return \TYPO3\CMS\Core\Core\Bootstrap
169 public function initializeCachingFramework() {
170 \TYPO3\CMS\Core\Cache\Cache
::initializeCachingFramework();
175 * Register autoloader
177 * @return \TYPO3\CMS\Core\Core\Bootstrap
179 public function registerAutoloader() {
180 if (PHP_VERSION_ID
< 50307) {
181 \TYPO3\CMS\Core\Compatibility\CompatbilityClassLoaderPhpBelow50307
::registerAutoloader();
183 \TYPO3\CMS\Core\Core\ClassLoader
::registerAutoloader();
189 * Checking for UTF-8 in the settings since TYPO3 4.5
191 * Since TYPO3 4.5, everything other than UTF-8 is deprecated.
193 * [BE][forceCharset] is set to the charset that TYPO3 is using
194 * [SYS][setDBinit] is used to set the DB connection
195 * and both settings need to be adjusted for UTF-8 in order to work properly
197 * @return \TYPO3\CMS\Core\Core\Bootstrap
199 public function checkUtf8DatabaseSettingsOrDie() {
200 // Check if [BE][forceCharset] has been set in localconf.php
201 if (isset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'])) {
202 // die() unless we're already on UTF-8
203 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] != 'utf-8' && $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] && TYPO3_enterInstallScript
!== '1') {
204 die('This installation was just upgraded to a new TYPO3 version. Since TYPO3 4.7, utf-8 is always enforced.<br />' . 'The configuration option $GLOBALS[\'TYPO3_CONF_VARS\'][BE][forceCharset] was marked as deprecated in TYPO3 4.5 and is now ignored.<br />' . 'You have configured the value to something different, which is not supported anymore.<br />' . 'Please proceed to the Update Wizard in the TYPO3 Install Tool to update your configuration.');
206 unset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
209 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']) && $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] !== '-1' && preg_match('/SET NAMES utf8/', $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']) === FALSE && TYPO3_enterInstallScript
!== '1') {
210 // Only accept "SET NAMES utf8" for this setting, otherwise die with a nice error
211 die('This TYPO3 installation is using the $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'setDBinit\'] property with the following value:' . chr(10) . $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] . chr(10) . chr(10) . 'It looks like UTF-8 is not used for this connection.' . chr(10) . chr(10) . 'Everything other than UTF-8 is unsupported since TYPO3 4.7.' . chr(10) . 'The DB, its connection and TYPO3 should be migrated to UTF-8 therefore. Please check your setup.');
213 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] = 'SET NAMES utf8;';
219 * Parse old curl options and set new http ones instead
221 * @TODO : This code segment must still be finished
222 * @return \TYPO3\CMS\Core\Core\Bootstrap
224 public function transferDeprecatedCurlSettings() {
225 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'])) {
226 $proxyParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'], 2);
227 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = $proxyParts[0];
228 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port'] = $proxyParts[1];
230 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'])) {
231 $userPassParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'], 2);
232 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'] = $userPassParts[0];
233 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_password'] = $userPassParts[1];
239 * Set cacheHash options
241 * @return \TYPO3\CMS\Core\Core\Bootstrap
243 public function setCacheHashOptions() {
244 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] = array(
245 'cachedParametersWhiteList' => \TYPO3\CMS\Core\Utility\GeneralUtility
::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashOnlyForParameters'], TRUE),
246 'excludedParameters' => \TYPO3\CMS\Core\Utility\GeneralUtility
::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'], TRUE),
247 'requireCacheHashPresenceParameters' => \TYPO3\CMS\Core\Utility\GeneralUtility
::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashRequiredParameters'], TRUE)
249 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty']) === '*') {
250 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludeAllEmptyParameters'] = TRUE;
252 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParametersIfEmpty'] = \TYPO3\CMS\Core\Utility\GeneralUtility
::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty'], TRUE);
258 * $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] must be either
259 * 'digest' or 'basic' with fallback to 'basic'
261 * @return \TYPO3\CMS\Core\Core\Bootstrap
263 public function enforceCorrectProxyAuthScheme() {
264 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] === 'digest' ?
: ($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] = 'basic');
269 * Set default timezone
271 * @return \TYPO3\CMS\Core\Core\Bootstrap
273 public function setDefaultTimezone() {
274 $timeZone = $GLOBALS['TYPO3_CONF_VARS']['SYS']['phpTimeZone'];
275 if (empty($timeZone)) {
276 // Time zone from the server environment (TZ env or OS query)
277 $defaultTimeZone = @date_default_timezone_get
();
278 if ($defaultTimeZone !== '') {
279 $timeZone = $defaultTimeZone;
284 // Set default to avoid E_WARNINGs with PHP > 5.3
285 date_default_timezone_set($timeZone);
290 * Initialize the locales handled by TYPO3
292 * @return \TYPO3\CMS\Core\Core\Bootstrap
294 public function initializeL10nLocales() {
295 \TYPO3\CMS\Core\Localization\Locales
::initialize();
300 * Based on the configuration of the image processing some options are forced
301 * to simplify configuration settings and combinations
303 * @return \TYPO3\CMS\Core\Core\Bootstrap
305 public function configureImageProcessingOptions() {
306 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['image_processing']) {
307 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] = 0;
308 $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'] = 0;
310 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
311 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'] = '';
312 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] = '';
313 $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] = 'gif,jpg,jpeg,png';
314 $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] = 0;
316 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']) {
317 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 1;
318 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_no_effects'] = 1;
319 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif'] = 1;
320 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] === 'gm') {
321 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 0;
322 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState'] = 0;
323 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_no_effects'] = 1;
324 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_v5effects'] = -1;
327 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState']) {
328 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ?
0 : 1;
334 * Convert type of "pageNotFound_handling" setting in case it was written as a
335 * string (e.g. if edited in Install Tool)
337 * @TODO : Remove, if the Install Tool handles such data types correctly
338 * @return \TYPO3\CMS\Core\Core\Bootstrap
340 public function convertPageNotFoundHandlingToBoolean() {
341 if (!strcasecmp($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'], 'TRUE')) {
342 $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = TRUE;
348 * Register xdebug(), debug(), debugBegin() and debugEnd() as global functions
350 * Note: Yes, this is possible in php! xdebug() is then a global function, even
351 * if registerGlobalDebugFunctions() is encapsulated in class scope.
353 * @return \TYPO3\CMS\Core\Core\Bootstrap
355 public function registerGlobalDebugFunctions() {
356 require_once('GlobalDebugFunctions.php');
361 * Mail sending via Swift Mailer
363 * @return \TYPO3\CMS\Core\Core\Bootstrap
365 public function registerSwiftMailer() {
366 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'][] = 'TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter';
371 * Configure and set up exception and error handling
373 * @return \TYPO3\CMS\Core\Core\Bootstrap
375 public function configureExceptionHandling() {
376 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
377 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'];
378 // Turn error logging on/off.
379 if (($displayErrors = intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'])) != '-1') {
380 // Special value "2" enables this feature only if $GLOBALS['TYPO3_CONF_VARS'][SYS][devIPmask] matches
381 if ($displayErrors == 2) {
382 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
388 if ($displayErrors == 0) {
389 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = 0;
391 if ($displayErrors == 1) {
392 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
393 define('TYPO3_ERRORHANDLER_MODE', 'debug');
395 @ini_set
('display_errors', $displayErrors);
396 } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility
::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
397 // With displayErrors = -1 (default), turn on debugging if devIPmask matches:
398 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
404 * Set PHP memory limit depending on value of
405 * $GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']
407 * @return \TYPO3\CMS\Core\Core\Bootstrap
409 public function setMemoryLimit() {
410 if (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) > 16) {
411 @ini_set
('memory_limit', (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) . 'm'));
417 * Define TYPO3_REQUESTTYPE* constants
418 * so devs exactly know what type of request it is
420 * @return \TYPO3\CMS\Core\Core\Bootstrap
422 public function defineTypo3RequestTypes() {
423 define('TYPO3_REQUESTTYPE_FE', 1);
424 define('TYPO3_REQUESTTYPE_BE', 2);
425 define('TYPO3_REQUESTTYPE_CLI', 4);
426 define('TYPO3_REQUESTTYPE_AJAX', 8);
427 define('TYPO3_REQUESTTYPE_INSTALL', 16);
428 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));
433 * Set up $GLOBALS['TYPO3_LOADED_EXT'] array with basic information
436 * @param boolean $allowCaching
437 * @return \TYPO3\CMS\Core\Core\Bootstrap
439 public function populateTypo3LoadedExtGlobal($allowCaching = TRUE) {
440 $GLOBALS['TYPO3_LOADED_EXT'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::loadTypo3LoadedExtensionInformation($allowCaching);
445 * Load extension configuration files (ext_localconf.php)
447 * The ext_localconf.php files in extensions are meant to make changes
448 * to the global $TYPO3_CONF_VARS configuration array.
450 * @param boolean $allowCaching
451 * @return \TYPO3\CMS\Core\Core\Bootstrap
453 public function loadAdditionalConfigurationFromExtensions($allowCaching = TRUE) {
454 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::loadExtLocalconf($allowCaching);
459 * Write deprecation log if deprecated extCache setting was set in the instance.
461 * @return \TYPO3\CMS\Core\Core\Bootstrap
462 * @deprecated since 6.0, the check will be removed two version later.
464 public function deprecationLogForOldExtCacheSetting() {
465 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && $GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] !== -1) {
466 \TYPO3\CMS\Core\Utility\GeneralUtility
::deprecationLog('Setting $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'extCache\'] is unused and can be removed from localconf.php');
472 * Initialize exception handling
474 * @return \TYPO3\CMS\Core\Core\Bootstrap
476 public function initializeExceptionHandling() {
477 if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] !== '') {
478 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'] !== '') {
479 // Register an error handler for the given errorHandlerErrors
480 $errorHandler = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors']);
481 // Set errors which will be converted in an exception
482 $errorHandler->setExceptionalErrors($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors']);
484 // Instantiate the exception handler once to make sure object is registered
485 // @TODO: Figure out if this is really needed
486 \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler']);
492 * Load some additional classes that are encapsulated in extensions
494 * @return \TYPO3\CMS\Core\Core\Bootstrap
496 public function requireAdditionalExtensionFiles() {
497 require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::extPath('lang') . 'lang.php';
502 * Extensions may register new caches, so we set the
503 * global cache array to the manager again at this point
505 * @return \TYPO3\CMS\Core\Core\Bootstrap
507 public function setFinalCachingFrameworkCacheConfiguration() {
508 $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
513 * Define logging and exception constants
515 * @return \TYPO3\CMS\Core\Core\Bootstrap
517 public function defineLoggingAndExceptionConstants() {
518 define('TYPO3_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']);
519 define('TYPO3_ERROR_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG']);
520 define('TYPO3_EXCEPTION_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG']);
525 * Unsetting reserved global variables:
526 * Those which are/can be set in "stddb/tables.php" files:
528 * @return \TYPO3\CMS\Core\Core\Bootstrap
530 public function unsetReservedGlobalVariables() {
531 unset($GLOBALS['PAGES_TYPES']);
532 unset($GLOBALS['TCA']);
533 unset($GLOBALS['TBE_MODULES']);
534 unset($GLOBALS['TBE_STYLES']);
535 unset($GLOBALS['FILEICONS']);
536 // Those set in init.php:
537 unset($GLOBALS['WEBMOUNTS']);
538 unset($GLOBALS['FILEMOUNTS']);
539 unset($GLOBALS['BE_USER']);
540 // Those set otherwise:
541 unset($GLOBALS['TBE_MODULES_EXT']);
542 unset($GLOBALS['TCA_DESCR']);
543 unset($GLOBALS['LOCAL_LANG']);
544 unset($GLOBALS['TYPO3_AJAX']);
549 * Initialize t3lib_db in $GLOBALS and connect if requested
551 * @param boolean $connect Whether or not the db should be connected already
552 * @return \TYPO3\CMS\Core\Core\Bootstrap
554 public function initializeTypo3DbGlobal($connect = TRUE) {
555 /** @var TYPO3_DB t3lib_db */
556 $GLOBALS['TYPO3_DB'] = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
557 $GLOBALS['TYPO3_DB']->debugOutput
= $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'];
559 $this->establishDatabaseConnection();
565 * Check adminOnly configuration variable and redirects
566 * to an URL in file typo3conf/LOCK_BACKEND or exit the script
568 * @throws \RuntimeException
569 * @return \TYPO3\CMS\Core\Core\Bootstrap
571 public function checkLockedBackendAndRedirectOrDie() {
572 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
573 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);
575 if (@is_file
((PATH_typo3conf
. 'LOCK_BACKEND'))) {
576 if (TYPO3_PROCEED_IF_NO_USER
=== 2) {
579 $fileContent = \TYPO3\CMS\Core\Utility\GeneralUtility
::getUrl(PATH_typo3conf
. 'LOCK_BACKEND');
581 header('Location: ' . $fileContent);
583 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);
592 * Compare client IP with IPmaskList and exit the script run
593 * if the client is not allowed to access the backend
595 * @return \TYPO3\CMS\Core\Core\Bootstrap
597 public function checkBackendIpOrDie() {
598 if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
599 if (!\TYPO3\CMS\Core\Utility\GeneralUtility
::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
600 // Send Not Found header - if the webserver can make use of it
601 header('Status: 404 Not Found');
602 // Just point us away from here...
603 header('Location: http://');
604 // ... and exit good!
612 * Check lockSSL configuration variable and redirect
613 * to https version of the backend if needed
615 * @return \TYPO3\CMS\Core\Core\Bootstrap
617 public function checkSslBackendAndRedirectIfNeeded() {
618 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'])) {
619 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort'])) {
620 $sslPortSuffix = ':' . intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort']);
624 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] == 3) {
625 $requestStr = substr(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_REQUEST_SCRIPT'), strlen(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir
));
626 if ($requestStr === 'index.php' && !\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_SSL')) {
627 list(, $url) = explode('://', \TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_REQUEST_URL'), 2);
628 list($server, $address) = explode('/', $url, 2);
629 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
632 } elseif (!\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_SSL')) {
633 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL']) === 2) {
634 list(, $url) = explode('://', \TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir
, 2);
635 list($server, $address) = explode('/', $url, 2);
636 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
638 // Send Not Found header - if the webserver can make use of it...
639 header('Status: 404 Not Found');
640 // Just point us away from here...
641 header('Location: http://');
643 // ... and exit good!
651 * Establish connection to the database
653 * @return \TYPO3\CMS\Core\Core\Bootstrap
655 public function establishDatabaseConnection() {
656 $GLOBALS['TYPO3_DB']->connectDB();
661 * Load ext_tables and friends.
663 * This will mainly set up $TCA and several other global arrays
664 * through API's like extMgm.
665 * Executes ext_tables.php files of loaded extensions or the
666 * according cache file if exists.
668 * Note: For backwards compatibility some global variables are
669 * explicitly set as global to be used without $GLOBALS[] in
670 * ext_tables.php. It is discouraged to access variables like
671 * $TBE_MODULES directly in ext_tables.php, but we can not prohibit
672 * this without heavily breaking backwards compatibility.
674 * @TODO : We could write a scheduler / reports module or an update checker
675 * @TODO : It should be defined, which global arrays are ok to be manipulated
676 * @param boolean $allowCaching True, if reading compiled ext_tables file from cache is allowed
677 * @return \TYPO3\CMS\Core\Core\Bootstrap
679 public function loadExtensionTables($allowCaching = TRUE) {
680 // It is discouraged to use those global variables directly, but we
681 // can not prohibit this without breaking backwards compatibility
682 global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
683 global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
684 global $PAGES_TYPES, $TBE_STYLES, $FILEICONS;
686 // Include standard tables.php file
687 require PATH_t3lib
. 'stddb/tables.php';
688 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::loadExtTables($allowCaching);
689 // Load additional ext tables script if registered
690 if (TYPO3_extTableDef_script
) {
691 include PATH_typo3conf
. TYPO3_extTableDef_script
;
693 // Run post hook for additional manipulation
694 $this->runExtTablesPostProcessingHooks();
699 * Check for registered ext tables hooks and run them
701 * @throws \UnexpectedValueException
702 * @return \TYPO3\CMS\Core\Core\Bootstrap
704 protected function runExtTablesPostProcessingHooks() {
705 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
706 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] as $classReference) {
707 /** @var $hookObject \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface */
708 $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility
::getUserObj($classReference);
709 if (!$hookObject instanceof \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface
) {
710 throw new \
UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\Database\\TableConfigurationPostProcessingHookInterface', 1320585902);
712 $hookObject->processData();
719 * Initialize sprite manager
721 * @return \TYPO3\CMS\Core\Core\Bootstrap
723 public function initializeSpriteManager() {
724 \TYPO3\CMS\Backend\Sprite\SpriteManager
::initialize();
729 * Initialize backend user object in globals
731 * @return \TYPO3\CMS\Core\Core\Bootstrap
733 public function initializeBackendUser() {
734 /** @var $backendUser \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */
735 $backendUser = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
736 $backendUser->warningEmail
= $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
737 $backendUser->lockIP
= $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'];
738 $backendUser->auth_timeout_field
= intval($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']);
739 $backendUser->OS
= TYPO3_OS
;
740 if (TYPO3_REQUESTTYPE
& TYPO3_REQUESTTYPE_CLI
) {
741 $backendUser->dontSetCookie
= TRUE;
743 $backendUser->start();
744 $backendUser->checkCLIuser();
745 $backendUser->backendCheckLogin();
746 $GLOBALS['BE_USER'] = $backendUser;
751 * Initialize backend user mount points
753 * @return \TYPO3\CMS\Core\Core\Bootstrap
755 public function initializeBackendUserMounts() {
756 // Includes deleted mount pages as well! @TODO: Figure out why ...
757 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
758 $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
763 * Initialize language object
765 * @return \TYPO3\CMS\Core\Core\Bootstrap
767 public function initializeLanguageObject() {
768 /** @var $GLOBALS['LANG'] \TYPO3\CMS\Lang\LanguageService */
769 $GLOBALS['LANG'] = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\CMS\Lang\LanguageService');
770 $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc
['lang']);
775 * Throw away all output that may have happened during bootstrapping by weird extensions
777 * @return \TYPO3\CMS\Core\Core\Bootstrap
779 public function endOutputBufferingAndCleanPreviousOutput() {
785 * Initialize output compression if configured
787 * @return \TYPO3\CMS\Core\Core\Bootstrap
789 public function initializeOutputCompression() {
790 if (extension_loaded('zlib') && $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']) {
791 if (\TYPO3\CMS\Core\Utility\MathUtility
::canBeInterpretedAsInteger($GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'])) {
792 @ini_set
('zlib.output_compression_level', $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']);
794 ob_start('ob_gzhandler');
800 * Initialize module menu object
802 * @return \TYPO3\CMS\Core\Core\Bootstrap
804 public function initializeModuleMenuObject() {
805 /** @var $moduleMenuUtility Typo3_BackendModule_Utility */
806 $moduleMenuUtility = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleController');
807 $moduleMenuUtility->createModuleMenu();
812 * Things that should be performed to shut down the framework.
813 * This method is called in all important scripts for a clean
814 * shut down of the system.
816 * @return \TYPO3\CMS\Core\Core\Bootstrap
818 public function shutdown() {
819 if (PHP_VERSION_ID
< 50307) {
820 \TYPO3\CMS\Core\Compatibility\CompatbilityClassLoaderPhpBelow50307
::unregisterAutoloader();
822 \TYPO3\CMS\Core\Core\ClassLoader
::unregisterAutoloader();
828 * Provides an instance of "template" for backend-modules to
831 * @return \TYPO3\CMS\Core\Core\Bootstrap
833 public function initializeBackendTemplate() {
834 $GLOBALS['TBE_TEMPLATE'] = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');