[!!!][TASK] Load extension configuration in function context
authorHelmut Hummel <helmut.hummel@typo3.org>
Sat, 16 Jun 2012 18:45:25 +0000 (20:45 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Sat, 16 Jun 2012 22:05:11 +0000 (00:05 +0200)
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
typo3/classes/Bootstrap/Backend.php

index d4cdd3d..c837a20 100644 (file)
@@ -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()
index 043629f..f9d99b2 100644 (file)
@@ -747,6 +747,49 @@ class Typo3_Bootstrap_Backend extends Typo3_Bootstrap_Abstract {
        }
 
        /**
+        * 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
+?>