From 721fe2aae079714c066283507dd81d7dec6d3fc9 Mon Sep 17 00:00:00 2001 From: Helmut Hummel <helmut.hummel@typo3.org> Date: Sat, 16 Jun 2012 20:45:25 +0200 Subject: [PATCH] [!!!][TASK] Load extension configuration in function context Until now all the ext_localconf.php files provided by extensions were included in a global scope. This is a major blocker for a clean and flexible bootstrapping. Include the configuration files in a method of the bootstrap class and set all supported global variables as global. Resolves: #38124 Releases: 6.0 Change-Id: I4e7136d39f85258f75f6f76cb60eeede8bfc0453 Reviewed-on: http://review.typo3.org/12139 Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn Reviewed-by: Oliver Hader Tested-by: Oliver Hader --- t3lib/config_default.php | 19 ++---------- typo3/classes/Bootstrap/Backend.php | 45 ++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/t3lib/config_default.php b/t3lib/config_default.php index d4cdd3dd78a8..c837a20bf8b6 100644 --- a/t3lib/config_default.php +++ b/t3lib/config_default.php @@ -42,23 +42,8 @@ Typo3_Bootstrap_Backend::getInstance() ->registerSwiftMailer() ->configureExceptionHandling() ->setMemoryLimit() - ->defineTypo3RequestTypes(); - - // Load extensions: -$TYPO3_LOADED_EXT = t3lib_extMgm::typo3_loadExtensions(); -if ($TYPO3_LOADED_EXT['_CACHEFILE']) { - require(PATH_typo3conf . $TYPO3_LOADED_EXT['_CACHEFILE'] . '_ext_localconf.php'); -} else { - $temp_TYPO3_LOADED_EXT = $TYPO3_LOADED_EXT; - foreach ($temp_TYPO3_LOADED_EXT as $_EXTKEY => $temp_lEDat) { - if (is_array($temp_lEDat) && $temp_lEDat['ext_localconf.php']) { - $_EXTCONF = $TYPO3_CONF_VARS['EXT']['extConf'][$_EXTKEY]; - require($temp_lEDat['ext_localconf.php']); - } - } -} - -Typo3_Bootstrap_Backend::getInstance() + ->defineTypo3RequestTypes() + ->loadAdditionalConfigurationFromExtensions() ->deprecationLogForOldXclassRegistration() ->initializeExceptionHandling() ->requireAdditionalExtensionFiles() diff --git a/typo3/classes/Bootstrap/Backend.php b/typo3/classes/Bootstrap/Backend.php index 043629f061a0..f9d99b2900d6 100644 --- a/typo3/classes/Bootstrap/Backend.php +++ b/typo3/classes/Bootstrap/Backend.php @@ -746,6 +746,49 @@ class Typo3_Bootstrap_Backend extends Typo3_Bootstrap_Abstract { return $this; } + /** + * Load extension configuration files (ext_localconf.php) + * + * The ext_localconf.php files in extensions are meant to make changes + * to the global $TYPO3_CONF_VARS configuration array. + * + * @return Typo3_Bootstrap_Backend + */ + public function loadAdditionalConfigurationFromExtensions() { + // This is the main array meant to be manipulated in the ext_localconf.php files + // In general it is recommended to not rely on it to be globally defined in that + // scope but to use $GLOBALS['TYPO3_CONF_VARS'] instead. + // Nevertheless we define it here as global for backwards compatibility. + global $TYPO3_CONF_VARS; + + // These globals for internal use only. Manipulating them directly is highly discouraged! + // We set them here as global for backwards compatibility, but this will change in + // future versions. + // @deprecated since 6.0 Will be removed in two versions. + global $T3_SERVICES, $T3_VAR; + + // Load extensions: + $GLOBALS['TYPO3_LOADED_EXT'] = t3lib_extMgm::typo3_loadExtensions(); + + // Load temp_CACHED file of ext_tables or each ext_tables.php of loaded extensions + if ($GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] + && file_exists(PATH_typo3conf . $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] . '_ext_localconf.php') + ) { + require(PATH_typo3conf . $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] . '_ext_localconf.php'); + } else { + foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $_EXTKEY => $extensionInformation) { + if (is_array($extensionInformation) && $extensionInformation['ext_localconf.php']) { + // $_EXTKEY and $_EXTCONF are available in ext_localconf.php + // and are explicitly set in temp_CACHED file as well + $_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]; + require($extensionInformation['ext_localconf.php']); + } + } + } + + return $this; + } + /** * Write deprecation log if the TYPO3 instance uses deprecated XCLASS * registrations via $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS'] @@ -1386,4 +1429,4 @@ class Typo3_Bootstrap_Backend extends Typo3_Bootstrap_Abstract { } } } -?> \ No newline at end of file +?> -- GitLab