[!!!][TASK] Move inclusion of ext_tables.php to bootstrap classes
authorChristian Kuhn <lolli@schwarzbu.ch>
Sat, 16 Jun 2012 17:05:57 +0000 (19:05 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sat, 16 Jun 2012 21:57:26 +0000 (23:57 +0200)
Change-Id: I6264ef8c94402dc53136ac502ea7d682a5141a1c
Releases: 6.0
Resolves: #38122
Reviewed-on: http://review.typo3.org/12135
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
NEWS.txt
t3lib/stddb/load_ext_tables.php [deleted file]
typo3/classes/Bootstrap/Backend.php
typo3/cli_dispatch.phpsh
typo3/init.php
typo3/sysext/cms/tslib/class.tslib_fe.php

index 6c99eec..9df9dd9 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -27,6 +27,20 @@ file, make sure to install a fresh version from 6.0 sources.
 The default TYPO3_CONF_VARS definitions where moved from t3lib/config_default.php
 to an own file in t3lib/stddb/DefaultSettings.php.
 
+* Removed TYPO3_tables_script constant
+
+It was possible to define a different base TCA definition file by defining the
+variable typo_db_tables_script in localconf.php. This functionality is removed
+without substitution.
+
+* Restricted access of global variables in ext_tables.php and ext_localconf.php
+
+With the bootstrap refactoring the visibility of ext_tables.php and
+ext_localconf.php was reduced. The files do not run in global context anymore,
+so variables like $TCA should be accessed through $GLOBALS['TCA']. There is a
+compatibility layer, but the core can not guarantee that extensions with
+strange setup does not break.
+
 * Deprecated methods
 
 Deprecated methods that were initially targeted to be removed in TYPO3 4.8/6.0
@@ -75,12 +89,6 @@ The ancient noBlur TypoScript setting for old Browsers (Internet Explorer <= 5.5
 was removed without alternative. The setting has no effect anymore and can be
 removed from custom TypoScript objects, especially MENU.
 
-* Removed TYPO3_tables_script constant
-
-It was possible to define a different base TCA definition file by defining the
-variable typo_db_tables_script in localconf.php. This functionality is removed
-without substitution.
-
 ===============================================================================
 Changes and Improvements
 ===============================================================================
diff --git a/t3lib/stddb/load_ext_tables.php b/t3lib/stddb/load_ext_tables.php
deleted file mode 100644 (file)
index 345df87..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-if (!defined('TYPO3_MODE')) {
-       die ('Access denied.');
-}
-
-/**
- * Loading the ext_tables.php files of the installed extensions when
- * caching to "temp_CACHED_" files is NOT enabled.
- * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @see tslib_fe::includeTCA(), typo3/init.php
- */
-$temp_TYPO3_LOADED_EXT = $GLOBALS['TYPO3_LOADED_EXT'];
-foreach ($temp_TYPO3_LOADED_EXT as $_EXTKEY => $temp_lEDat) {
-       if (is_array($temp_lEDat) && $temp_lEDat['ext_tables.php']) {
-               $_EXTCONF = $TYPO3_CONF_VARS['EXT']['extConf'][$_EXTKEY];
-               require($temp_lEDat['ext_tables.php']);
-       }
-}
-?>
\ No newline at end of file
index 7dd48d5..043629f 100644 (file)
@@ -983,12 +983,72 @@ class Typo3_Bootstrap_Backend extends Typo3_Bootstrap_Abstract {
        }
 
        /**
+        * Load ext_tables and friends.
+        *
+        * This will mainly set up $TCA and several other global arrays
+        * through API's like extMgm.
+        * Executes ext_tables.php files of loaded extensions or the
+        * according typo3conf/temp_CACHED_*_ext_tables.php if exists.
+        *
+        * Note: For backwards compatibility some global variables are
+        * explicitly set as global to be used without $GLOBALS[] in
+        * ext_tables.php. It is discouraged to access variables like
+        * $TBE_MODULES directly in ext_tables.php, but we can not prohibit
+        * this without heavily breaking backwards compatibility.
+        * @TODO: We could write a scheduler / reports module or an update checker
+        * that hints extension authors about discouraged direct variable access.
+        *
+        * Note: include / require are used instead of include_once / require_once on
+        * purpose here: in FE (tslib_fe), this method here can be loaded mulitple times
+        *
+        * @TODO: It should be defined, which global arrays are ok to be manipulated
+        *
+        * @return Typo3_Bootstrap_Backend
+        */
+       public function loadExtensionTables() {
+               global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
+               global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
+               global $PAGES_TYPES, $TBE_STYLES, $FILEICONS;
+
+                       // Include standard tables.php file
+               require(PATH_t3lib . 'stddb/tables.php');
+
+               if (
+                       $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE']
+                       && file_exists(PATH_typo3conf . $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] . '_ext_tables.php')
+               ) {
+                               // Load temp_CACHED_x_ext_tables.php file if exists
+                       require(PATH_typo3conf . $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] . '_ext_tables.php');
+               } else {
+                               // Load each ext_tables.php file of loaded extensions
+                       foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $_EXTKEY => $extensionInformation) {
+                               if (is_array($extensionInformation) && $extensionInformation['ext_tables.php']) {
+                                               // $_EXTKEY and $_EXTCONF are available in ext_tables.php
+                                               // and are explicitly set in temp_CACHED file as well
+                                       $_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY];
+                                       require($extensionInformation['ext_tables.php']);
+                               }
+                       }
+               }
+
+                       // Load additional ext tables script if registered
+               if (TYPO3_extTableDef_script) {
+                       include(PATH_typo3conf . TYPO3_extTableDef_script);
+               }
+
+                       // Run post hook for additional manipulation
+               $this->runExtTablesPostProcessingHooks();
+
+               return $this;
+       }
+
+       /**
         * Check for registered ext tables hooks and run them
         *
         * @throws UnexpectedValueException
         * @return Typo3_Bootstrap_Backend
         */
-       public function runExtTablesPostProcessingHooks() {
+       protected function runExtTablesPostProcessingHooks() {
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] as $classReference) {
                                        /** @var $hookObject t3lib_extTables_PostProcessingHook */
index 1b44e4b..86f83e4 100755 (executable)
@@ -57,25 +57,10 @@ Typo3_Bootstrap_Backend::getInstance()
 require(PATH_t3lib . 'config_default.php');
 
 Typo3_Bootstrap_Backend::getInstance()->initializeTypo3DbGlobal(TRUE);
-
 Typo3_Bootstrap_Cli::getInstance()->initializeCliKeyOrDie();
-
-       // Include standard tables.php file
-include(PATH_t3lib . 'stddb/tables.php');
-       // Load temp_CACHED file of ext_tables or each ext_tables.php of loaded extensions
-if ($TYPO3_LOADED_EXT['_CACHEFILE']) {
-       include(PATH_typo3conf . $TYPO3_LOADED_EXT['_CACHEFILE'] . '_ext_tables.php');
-} else {
-       include(PATH_t3lib . 'stddb/load_ext_tables.php');
-}
-       // Load additional ext tables script
-if (TYPO3_extTableDef_script) {
-       include(PATH_typo3conf . TYPO3_extTableDef_script);
-}
-Typo3_Bootstrap_Backend::getInstance()->runExtTablesPostProcessingHooks();
-
-       // TODO: Check if we really need the sprite manager on the command line
 Typo3_Bootstrap_Backend::getInstance()
+       ->loadExtensionTables()
+               // TODO: Check if we really need the sprite manager on the command line
        ->initializeSpriteManager(TRUE)
        ->initializeBackendUser()
        ->initializeBackendUserMounts()
index f969332..a7eba59 100644 (file)
@@ -93,21 +93,8 @@ if (!$CLIENT['BROWSER']) {
        throw new RuntimeException('Browser Error: Your browser version looks incompatible with this TYPO3 version!', 1294587023);
 }
 
-       // Include standard tables.php file
-include(PATH_t3lib . 'stddb/tables.php');
-       // Load temp_CACHED file of ext_tables or each ext_tables.php of loaded extensions
-if ($TYPO3_LOADED_EXT['_CACHEFILE']) {
-       include(PATH_typo3conf . $TYPO3_LOADED_EXT['_CACHEFILE'] . '_ext_tables.php');
-} else {
-       include(PATH_t3lib . 'stddb/load_ext_tables.php');
-}
-       // Load additional ext tables script
-if (TYPO3_extTableDef_script) {
-       include(PATH_typo3conf . TYPO3_extTableDef_script);
-}
-
 Typo3_Bootstrap_Backend::getInstance()
-       ->runExtTablesPostProcessingHooks()
+       ->loadExtensionTables()
        ->initializeSpriteManager(TRUE)
        ->initializeBackendUser()
        ->initializeBackendUserMounts()
index abb009f..65ec0a8 100644 (file)
@@ -2063,30 +2063,15 @@ class tslib_fe {
         * full TCA for the table, use t3lib_div::loadTCA($tableName) after calling
         * this function.
         *
-        * @param       boolean         Probably, keep hands of this value. Just don't set it. (This may affect the first-ever time this function is called since if you set it to zero/FALSE any subsequent call will still trigger the inclusion; In other words, this value will be set in $this->TCAloaded after inclusion and therefore if its FALSE, another inclusion will be possible on the next call. See ->getCompressedTCarray())
-        * @return      void
+        * @param integer $TCAloaded Probably, keep hands of this value. Just don't set it. (This may affect the first-ever time this function is called since if you set it to zero/FALSE any subsequent call will still trigger the inclusion; In other words, this value will be set in $this->TCAloaded after inclusion and therefore if its FALSE, another inclusion will be possible on the next call. See ->getCompressedTCarray())
+        * @return void
         * @see getCompressedTCarray()
         */
-       function includeTCA($TCAloaded = 1) {
-                       // do not remove this global declaration - it's used inside the ext_tables.php files
-               global $TCA;
+       public function includeTCA($TCAloaded = 1) {
                if (!$this->TCAloaded) {
                        $GLOBALS['TCA'] = array();
-                       include(PATH_t3lib . 'stddb/tables.php');
-                               // Extension additions
-                       if ($GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] && file_exists(PATH_typo3conf . $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] . '_ext_tables.php')) {
-                               include(PATH_typo3conf.$GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'].'_ext_tables.php');
-                       } else {
-                               include(PATH_t3lib.'stddb/load_ext_tables.php');
-                       }
-                               // ext-script
-                       if (TYPO3_extTableDef_script) {
-                               include (PATH_typo3conf.TYPO3_extTableDef_script);
-                       }
-
+                       Typo3_Bootstrap_Backend::getInstance()->loadExtensionTables();
                        $this->TCAloaded = $TCAloaded;
-
-                       Typo3_Bootstrap_Backend::getInstance()->runExtTablesPostProcessingHooks();
                }
        }
 
@@ -4751,4 +4736,4 @@ if (version == "n3") {
                return $result;
        }
 }
-?>
+?>
\ No newline at end of file