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\Extension\ExtensionManager
::registerExtDirectComponent('TYPO3.Components.PageTree.DataProvider', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeDataProvider', 'web', 'user,group');
117 \TYPO3\CMS\Core\Extension\ExtensionManager
::registerExtDirectComponent('TYPO3.Components.PageTree.Commands', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeCommands', 'web', 'user,group');
118 \TYPO3\CMS\Core\Extension\ExtensionManager
::registerExtDirectComponent('TYPO3.Components.PageTree.ContextMenuDataProvider', 'TYPO3\\CMS\\Backend\\ContextMenu\\Pagetree\\Extdirect\\ContextMenuConfiguration', 'web', 'user,group');
119 \TYPO3\CMS\Core\Extension\ExtensionManager
::registerExtDirectComponent('TYPO3.LiveSearchActions.ExtDirect', 'TYPO3\\CMS\\Backend\\Search\\LiveSearch\\ExtDirect\\LiveSearchDataProvider', 'web_list', 'user,group');
120 \TYPO3\CMS\Core\Extension\ExtensionManager
::registerExtDirectComponent('TYPO3.BackendUserSettings.ExtDirect', 'TYPO3\\CMS\\Backend\\User\\ExtDirect\\BackendUserSettingsDataProvider');
121 \TYPO3\CMS\Core\Extension\ExtensionManager
::registerExtDirectComponent('TYPO3.CSH.ExtDirect', 'TYPO3\\CMS\\ContextHelp\\ExtDirect\\ContextHelpDataProvider');
122 \TYPO3\CMS\Core\Extension\ExtensionManager
::registerExtDirectComponent('TYPO3.ExtDirectStateProvider.ExtDirect', 'TYPO3\\CMS\\Backend\\InterfaceState\\ExtDirect\\DataProvider');
128 * Populate the local configuration.
129 * Merge default TYPO3_CONF_VARS with content of typo3conf/LocalConfiguration.php,
130 * execute typo3conf/AdditionalConfiguration.php, define database related constants.
132 * @return \TYPO3\CMS\Core\Core\Bootstrap
134 public function populateLocalConfiguration() {
136 \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager')->exportConfiguration();
137 } catch (\Exception
$e) {
138 die($e->getMessage());
140 define('TYPO3_db', $GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
141 define('TYPO3_db_username', $GLOBALS['TYPO3_CONF_VARS']['DB']['username']);
142 define('TYPO3_db_password', $GLOBALS['TYPO3_CONF_VARS']['DB']['password']);
143 define('TYPO3_db_host', $GLOBALS['TYPO3_CONF_VARS']['DB']['host']);
144 define('TYPO3_extTableDef_script', $GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript']);
145 unset($GLOBALS['TYPO3_CONF_VARS']['DB']);
146 define('TYPO3_user_agent', 'User-Agent: ' . $GLOBALS['TYPO3_CONF_VARS']['HTTP']['userAgent']);
151 * Redirect to install tool if database host and database are not defined
153 * @return \TYPO3\CMS\Core\Core\Bootstrap
155 public function redirectToInstallToolIfDatabaseCredentialsAreMissing() {
156 if (!TYPO3_db_host
&& !TYPO3_db
) {
157 \TYPO3\CMS\Core\Utility\HttpUtility
::redirect('install/index.php?mode=123&step=1&password=joh316');
163 * Initialize caching framework
165 * @return \TYPO3\CMS\Core\Core\Bootstrap
167 public function initializeCachingFramework() {
168 \TYPO3\CMS\Core\Cache\Cache
::initializeCachingFramework();
173 * Register autoloader
175 * @return \TYPO3\CMS\Core\Core\Bootstrap
177 public function registerAutoloader() {
178 if (PHP_VERSION_ID
< 50307) {
179 \TYPO3\CMS\Core\Compatibility\CompatbilityClassLoaderPhpBelow50307
::registerAutoloader();
181 \TYPO3\CMS\Core\Core\ClassLoader
::registerAutoloader();
187 * Checking for UTF-8 in the settings since TYPO3 4.5
189 * Since TYPO3 4.5, everything other than UTF-8 is deprecated.
191 * [BE][forceCharset] is set to the charset that TYPO3 is using
192 * [SYS][setDBinit] is used to set the DB connection
193 * and both settings need to be adjusted for UTF-8 in order to work properly
195 * @return \TYPO3\CMS\Core\Core\Bootstrap
197 public function checkUtf8DatabaseSettingsOrDie() {
198 // Check if [BE][forceCharset] has been set in localconf.php
199 if (isset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'])) {
200 // die() unless we're already on UTF-8
201 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] != 'utf-8' && $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] && TYPO3_enterInstallScript
!== '1') {
202 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.');
204 unset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
207 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') {
208 // Only accept "SET NAMES utf8" for this setting, otherwise die with a nice error
209 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.');
211 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] = 'SET NAMES utf8;';
217 * Parse old curl options and set new http ones instead
219 * @TODO : This code segment must still be finished
220 * @return \TYPO3\CMS\Core\Core\Bootstrap
222 public function transferDeprecatedCurlSettings() {
223 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'])) {
224 $proxyParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'], 2);
225 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = $proxyParts[0];
226 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port'] = $proxyParts[1];
228 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'])) {
229 $userPassParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'], 2);
230 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'] = $userPassParts[0];
231 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_password'] = $userPassParts[1];
237 * Set cacheHash options
239 * @return \TYPO3\CMS\Core\Core\Bootstrap
241 public function setCacheHashOptions() {
242 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] = array(
243 'cachedParametersWhiteList' => \TYPO3\CMS\Core\Utility\GeneralUtility
::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashOnlyForParameters'], TRUE),
244 'excludedParameters' => \TYPO3\CMS\Core\Utility\GeneralUtility
::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'], TRUE),
245 'requireCacheHashPresenceParameters' => \TYPO3\CMS\Core\Utility\GeneralUtility
::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashRequiredParameters'], TRUE)
247 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty']) === '*') {
248 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludeAllEmptyParameters'] = TRUE;
250 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParametersIfEmpty'] = \TYPO3\CMS\Core\Utility\GeneralUtility
::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty'], TRUE);
256 * $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] must be either
257 * 'digest' or 'basic' with fallback to 'basic'
259 * @return \TYPO3\CMS\Core\Core\Bootstrap
261 public function enforceCorrectProxyAuthScheme() {
262 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] === 'digest' ?
: ($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] = 'basic');
267 * Set default timezone
269 * @return \TYPO3\CMS\Core\Core\Bootstrap
271 public function setDefaultTimezone() {
272 $timeZone = $GLOBALS['TYPO3_CONF_VARS']['SYS']['phpTimeZone'];
273 if (empty($timeZone)) {
274 // Time zone from the server environment (TZ env or OS query)
275 $defaultTimeZone = @date_default_timezone_get
();
276 if ($defaultTimeZone !== '') {
277 $timeZone = $defaultTimeZone;
282 // Set default to avoid E_WARNINGs with PHP > 5.3
283 date_default_timezone_set($timeZone);
288 * Initialize the locales handled by TYPO3
290 * @return \TYPO3\CMS\Core\Core\Bootstrap
292 public function initializeL10nLocales() {
293 \TYPO3\CMS\Core\Localization\Locales
::initialize();
298 * Based on the configuration of the image processing some options are forced
299 * to simplify configuration settings and combinations
301 * @return \TYPO3\CMS\Core\Core\Bootstrap
303 public function configureImageProcessingOptions() {
304 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['image_processing']) {
305 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] = 0;
306 $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'] = 0;
308 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
309 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'] = '';
310 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] = '';
311 $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] = 'gif,jpg,jpeg,png';
312 $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] = 0;
314 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']) {
315 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 1;
316 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_no_effects'] = 1;
317 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif'] = 1;
318 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] === 'gm') {
319 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 0;
320 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState'] = 0;
321 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_no_effects'] = 1;
322 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_v5effects'] = -1;
325 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState']) {
326 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ?
0 : 1;
332 * Convert type of "pageNotFound_handling" setting in case it was written as a
333 * string (e.g. if edited in Install Tool)
335 * @TODO : Remove, if the Install Tool handles such data types correctly
336 * @return \TYPO3\CMS\Core\Core\Bootstrap
338 public function convertPageNotFoundHandlingToBoolean() {
339 if (!strcasecmp($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'], 'TRUE')) {
340 $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = TRUE;
346 * Register xdebug(), debug(), debugBegin() and debugEnd() as global functions
348 * Note: Yes, this is possible in php! xdebug() is then a global function, even
349 * if registerGlobalDebugFunctions() is encapsulated in class scope.
351 * @return \TYPO3\CMS\Core\Core\Bootstrap
353 public function registerGlobalDebugFunctions() {
354 require_once('GlobalDebugFunctions.php');
359 * Mail sending via Swift Mailer
361 * @return \TYPO3\CMS\Core\Core\Bootstrap
363 public function registerSwiftMailer() {
364 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'][] = 'TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter';
369 * Configure and set up exception and error handling
371 * @return \TYPO3\CMS\Core\Core\Bootstrap
373 public function configureExceptionHandling() {
374 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
375 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'];
376 // Turn error logging on/off.
377 if (($displayErrors = intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'])) != '-1') {
378 // Special value "2" enables this feature only if $GLOBALS['TYPO3_CONF_VARS'][SYS][devIPmask] matches
379 if ($displayErrors == 2) {
380 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
386 if ($displayErrors == 0) {
387 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = 0;
389 if ($displayErrors == 1) {
390 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
391 define('TYPO3_ERRORHANDLER_MODE', 'debug');
393 @ini_set
('display_errors', $displayErrors);
394 } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility
::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
395 // With displayErrors = -1 (default), turn on debugging if devIPmask matches:
396 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
402 * Set PHP memory limit depending on value of
403 * $GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']
405 * @return \TYPO3\CMS\Core\Core\Bootstrap
407 public function setMemoryLimit() {
408 if (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) > 16) {
409 @ini_set
('memory_limit', (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) . 'm'));
415 * Define TYPO3_REQUESTTYPE* constants
416 * so devs exactly know what type of request it is
418 * @return \TYPO3\CMS\Core\Core\Bootstrap
420 public function defineTypo3RequestTypes() {
421 define('TYPO3_REQUESTTYPE_FE', 1);
422 define('TYPO3_REQUESTTYPE_BE', 2);
423 define('TYPO3_REQUESTTYPE_CLI', 4);
424 define('TYPO3_REQUESTTYPE_AJAX', 8);
425 define('TYPO3_REQUESTTYPE_INSTALL', 16);
426 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));
431 * Set up $GLOBALS['TYPO3_LOADED_EXT'] array with basic information
434 * @param boolean $allowCaching
435 * @return \TYPO3\CMS\Core\Core\Bootstrap
437 public function populateTypo3LoadedExtGlobal($allowCaching = TRUE) {
438 $GLOBALS['TYPO3_LOADED_EXT'] = \TYPO3\CMS\Core\Extension\ExtensionManager
::loadTypo3LoadedExtensionInformation($allowCaching);
443 * Load extension configuration files (ext_localconf.php)
445 * The ext_localconf.php files in extensions are meant to make changes
446 * to the global $TYPO3_CONF_VARS configuration array.
448 * @param boolean $allowCaching
449 * @return \TYPO3\CMS\Core\Core\Bootstrap
451 public function loadAdditionalConfigurationFromExtensions($allowCaching = TRUE) {
452 \TYPO3\CMS\Core\Extension\ExtensionManager
::loadExtLocalconf($allowCaching);
457 * Write deprecation log if deprecated extCache setting was set in the instance.
459 * @return \TYPO3\CMS\Core\Core\Bootstrap
460 * @deprecated since 6.0, the check will be removed two version later.
462 public function deprecationLogForOldExtCacheSetting() {
463 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && $GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] !== -1) {
464 \TYPO3\CMS\Core\Utility\GeneralUtility
::deprecationLog('Setting $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'extCache\'] is unused and can be removed from localconf.php');
470 * Initialize exception handling
472 * @return \TYPO3\CMS\Core\Core\Bootstrap
474 public function initializeExceptionHandling() {
475 if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] !== '') {
476 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'] !== '') {
477 // Register an error handler for the given errorHandlerErrors
478 $errorHandler = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors']);
479 // Set errors which will be converted in an exception
480 $errorHandler->setExceptionalErrors($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors']);
482 // Instantiate the exception handler once to make sure object is registered
483 // @TODO: Figure out if this is really needed
484 \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler']);
490 * Load some additional classes that are encapsulated in extensions
492 * @return \TYPO3\CMS\Core\Core\Bootstrap
494 public function requireAdditionalExtensionFiles() {
495 require_once \TYPO3\CMS\Core\Extension\ExtensionManager
::extPath('lang') . 'lang.php';
500 * Extensions may register new caches, so we set the
501 * global cache array to the manager again at this point
503 * @return \TYPO3\CMS\Core\Core\Bootstrap
505 public function setFinalCachingFrameworkCacheConfiguration() {
506 $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
511 * Define logging and exception constants
513 * @return \TYPO3\CMS\Core\Core\Bootstrap
515 public function defineLoggingAndExceptionConstants() {
516 define('TYPO3_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']);
517 define('TYPO3_ERROR_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG']);
518 define('TYPO3_EXCEPTION_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG']);
523 * Unsetting reserved global variables:
524 * Those which are/can be set in "stddb/tables.php" files:
526 * @return \TYPO3\CMS\Core\Core\Bootstrap
528 public function unsetReservedGlobalVariables() {
529 unset($GLOBALS['PAGES_TYPES']);
530 unset($GLOBALS['TCA']);
531 unset($GLOBALS['TBE_MODULES']);
532 unset($GLOBALS['TBE_STYLES']);
533 unset($GLOBALS['FILEICONS']);
534 // Those set in init.php:
535 unset($GLOBALS['WEBMOUNTS']);
536 unset($GLOBALS['FILEMOUNTS']);
537 unset($GLOBALS['BE_USER']);
538 // Those set otherwise:
539 unset($GLOBALS['TBE_MODULES_EXT']);
540 unset($GLOBALS['TCA_DESCR']);
541 unset($GLOBALS['LOCAL_LANG']);
542 unset($GLOBALS['TYPO3_AJAX']);
547 * Initialize t3lib_db in $GLOBALS and connect if requested
549 * @param boolean $connect Whether or not the db should be connected already
550 * @return \TYPO3\CMS\Core\Core\Bootstrap
552 public function initializeTypo3DbGlobal($connect = TRUE) {
553 /** @var TYPO3_DB t3lib_db */
554 $GLOBALS['TYPO3_DB'] = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
555 $GLOBALS['TYPO3_DB']->debugOutput
= $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'];
557 $this->establishDatabaseConnection();
563 * Check adminOnly configuration variable and redirects
564 * to an URL in file typo3conf/LOCK_BACKEND or exit the script
566 * @throws \RuntimeException
567 * @return \TYPO3\CMS\Core\Core\Bootstrap
569 public function checkLockedBackendAndRedirectOrDie() {
570 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
571 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);
573 if (@is_file
((PATH_typo3conf
. 'LOCK_BACKEND'))) {
574 if (TYPO3_PROCEED_IF_NO_USER
=== 2) {
577 $fileContent = \TYPO3\CMS\Core\Utility\GeneralUtility
::getUrl(PATH_typo3conf
. 'LOCK_BACKEND');
579 header('Location: ' . $fileContent);
581 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);
590 * Compare client IP with IPmaskList and exit the script run
591 * if the client is not allowed to access the backend
593 * @return \TYPO3\CMS\Core\Core\Bootstrap
595 public function checkBackendIpOrDie() {
596 if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
597 if (!\TYPO3\CMS\Core\Utility\GeneralUtility
::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
598 // Send Not Found header - if the webserver can make use of it
599 header('Status: 404 Not Found');
600 // Just point us away from here...
601 header('Location: http://');
602 // ... and exit good!
610 * Check lockSSL configuration variable and redirect
611 * to https version of the backend if needed
613 * @return \TYPO3\CMS\Core\Core\Bootstrap
615 public function checkSslBackendAndRedirectIfNeeded() {
616 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'])) {
617 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort'])) {
618 $sslPortSuffix = ':' . intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort']);
622 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] == 3) {
623 $requestStr = substr(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_REQUEST_SCRIPT'), strlen(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir
));
624 if ($requestStr === 'index.php' && !\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_SSL')) {
625 list(, $url) = explode('://', \TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_REQUEST_URL'), 2);
626 list($server, $address) = explode('/', $url, 2);
627 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
630 } elseif (!\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_SSL')) {
631 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL']) === 2) {
632 list(, $url) = explode('://', \TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir
, 2);
633 list($server, $address) = explode('/', $url, 2);
634 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
636 // Send Not Found header - if the webserver can make use of it...
637 header('Status: 404 Not Found');
638 // Just point us away from here...
639 header('Location: http://');
641 // ... and exit good!
649 * Establish connection to the database
651 * @return \TYPO3\CMS\Core\Core\Bootstrap
653 public function establishDatabaseConnection() {
654 $GLOBALS['TYPO3_DB']->connectDB();
659 * Load ext_tables and friends.
661 * This will mainly set up $TCA and several other global arrays
662 * through API's like extMgm.
663 * Executes ext_tables.php files of loaded extensions or the
664 * according cache file if exists.
666 * Note: For backwards compatibility some global variables are
667 * explicitly set as global to be used without $GLOBALS[] in
668 * ext_tables.php. It is discouraged to access variables like
669 * $TBE_MODULES directly in ext_tables.php, but we can not prohibit
670 * this without heavily breaking backwards compatibility.
672 * @TODO : We could write a scheduler / reports module or an update checker
673 * @TODO : It should be defined, which global arrays are ok to be manipulated
674 * @param boolean $allowCaching True, if reading compiled ext_tables file from cache is allowed
675 * @return \TYPO3\CMS\Core\Core\Bootstrap
677 public function loadExtensionTables($allowCaching = TRUE) {
678 // It is discouraged to use those global variables directly, but we
679 // can not prohibit this without breaking backwards compatibility
680 global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
681 global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
682 global $PAGES_TYPES, $TBE_STYLES, $FILEICONS;
684 // Include standard tables.php file
685 require PATH_t3lib
. 'stddb/tables.php';
686 \TYPO3\CMS\Core\Extension\ExtensionManager
::loadExtTables($allowCaching);
687 // Load additional ext tables script if registered
688 if (TYPO3_extTableDef_script
) {
689 include PATH_typo3conf
. TYPO3_extTableDef_script
;
691 // Run post hook for additional manipulation
692 $this->runExtTablesPostProcessingHooks();
697 * Check for registered ext tables hooks and run them
699 * @throws \UnexpectedValueException
700 * @return \TYPO3\CMS\Core\Core\Bootstrap
702 protected function runExtTablesPostProcessingHooks() {
703 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
704 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] as $classReference) {
705 /** @var $hookObject \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface */
706 $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility
::getUserObj($classReference);
707 if (!$hookObject instanceof \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface
) {
708 throw new \
UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\Database\\TableConfigurationPostProcessingHookInterface', 1320585902);
710 $hookObject->processData();
717 * Initialize sprite manager
719 * @return \TYPO3\CMS\Core\Core\Bootstrap
721 public function initializeSpriteManager() {
722 \TYPO3\CMS\Backend\Sprite\SpriteManager
::initialize();
727 * Initialize backend user object in globals
729 * @return \TYPO3\CMS\Core\Core\Bootstrap
731 public function initializeBackendUser() {
732 /** @var $backendUser \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */
733 $backendUser = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
734 $backendUser->warningEmail
= $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
735 $backendUser->lockIP
= $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'];
736 $backendUser->auth_timeout_field
= intval($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']);
737 $backendUser->OS
= TYPO3_OS
;
738 if (TYPO3_REQUESTTYPE
& TYPO3_REQUESTTYPE_CLI
) {
739 $backendUser->dontSetCookie
= TRUE;
741 $backendUser->start();
742 $backendUser->checkCLIuser();
743 $backendUser->backendCheckLogin();
744 $GLOBALS['BE_USER'] = $backendUser;
749 * Initialize backend user mount points
751 * @return \TYPO3\CMS\Core\Core\Bootstrap
753 public function initializeBackendUserMounts() {
754 // Includes deleted mount pages as well! @TODO: Figure out why ...
755 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
756 $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
761 * Initialize language object
763 * @return \TYPO3\CMS\Core\Core\Bootstrap
765 public function initializeLanguageObject() {
766 /** @var $GLOBALS['LANG'] \TYPO3\CMS\Lang\LanguageService */
767 $GLOBALS['LANG'] = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\CMS\Lang\LanguageService');
768 $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc
['lang']);
773 * Throw away all output that may have happened during bootstrapping by weird extensions
775 * @return \TYPO3\CMS\Core\Core\Bootstrap
777 public function endOutputBufferingAndCleanPreviousOutput() {
783 * Initialize output compression if configured
785 * @return \TYPO3\CMS\Core\Core\Bootstrap
787 public function initializeOutputCompression() {
788 if (extension_loaded('zlib') && $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']) {
789 if (\TYPO3\CMS\Core\Utility\MathUtility
::canBeInterpretedAsInteger($GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'])) {
790 @ini_set
('zlib.output_compression_level', $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']);
792 ob_start('ob_gzhandler');
798 * Initialize module menu object
800 * @return \TYPO3\CMS\Core\Core\Bootstrap
802 public function initializeModuleMenuObject() {
803 /** @var $moduleMenuUtility Typo3_BackendModule_Utility */
804 $moduleMenuUtility = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleController');
805 $moduleMenuUtility->createModuleMenu();
810 * Things that should be performed to shut down the framework.
811 * This method is called in all important scripts for a clean
812 * shut down of the system.
814 * @return \TYPO3\CMS\Core\Core\Bootstrap
816 public function shutdown() {
817 if (PHP_VERSION_ID
< 50307) {
818 \TYPO3\CMS\Core\Compatibility\CompatbilityClassLoaderPhpBelow50307
::unregisterAutoloader();
820 \TYPO3\CMS\Core\Core\ClassLoader
::unregisterAutoloader();
826 * Provides an instance of "template" for backend-modules to
829 * @return \TYPO3\CMS\Core\Core\Bootstrap
831 public function initializeBackendTemplate() {
832 $GLOBALS['TBE_TEMPLATE'] = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');