Fixed #11474: Performance improvement: Store separate extlist for the frontend
authorRupert Germann <rupi@gmx.li>
Wed, 5 Aug 2009 12:42:42 +0000 (12:42 +0000)
committerRupert Germann <rupi@gmx.li>
Wed, 5 Aug 2009 12:42:42 +0000 (12:42 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5765 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_extmgm.php
typo3/mod/tools/em/class.em_index.php

index 92d4deb..5afb86a 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,8 +5,9 @@
 2009-08-05  Rupert Germann  <rupi@gmx.li>
 
        * Fixed bug #11539: t3ver_stage will not be resetted when t3ver_stage was >0 before (thanks to Fabrizio Branca)
-       * Fixed #11430: Performance improvement: use $GLOBALS['EXEC_TIME'] instead of time() where it makes sense (Thanks to Niels Pardon)
+       * Fixed #11430: Performance improvement: use $GLOBALS['EXEC_TIME'] instead of time() where it makes sense (thanks to Niels Pardon)
        * Fixed #11512: Performance improvement: replace while(list()...) by foreach in the TYPO3 core (part 1)
+       * Fixed #11474: Performance improvement: Store separate extlist for the frontend (thanks to Mathias Schreiber)
 
 2009-08-04  Michael Stucki  <michael@typo3.org>
 
index 50bbb05..ec14179 100644 (file)
@@ -1202,8 +1202,20 @@ tt_content.'.$key.$prefix.' {
        public static function typo3_loadExtensions() {
                global $TYPO3_CONF_VARS;
 
+                       // Select mode how to load extensions in order to speed up the FE
+               if (TYPO3_MODE == 'FE') {
+                       if (!($extLoadInContext = $TYPO3_CONF_VARS['EXT']['extList_FE'])) {
+                                       // fall back to standard 'extList' if 'extList_FE' is not (yet) set
+                               $extLoadInContext = $TYPO3_CONF_VARS['EXT']['extList'];
+                       }
+                       $cacheFileSuffix = '_FE';
+               } else {
+                       $extLoadInContext = $TYPO3_CONF_VARS['EXT']['extList'];
+                               // Works as before
+                       $cacheFileSuffix = '';
+               }
                        // Full list of extensions includes both required and extList:
-               $rawExtList = $TYPO3_CONF_VARS['EXT']['requiredExt'].','.$TYPO3_CONF_VARS['EXT']['extList'];
+               $rawExtList = $TYPO3_CONF_VARS['EXT']['requiredExt'] . ',' . $extLoadInContext;
 
                        // Empty array as a start.
                $extensions = array();
@@ -1211,7 +1223,7 @@ tt_content.'.$key.$prefix.' {
                        //
                if ($rawExtList) {
                                // The cached File prefix.
-                       $cacheFilePrefix = 'temp_CACHED';
+                       $cacheFilePrefix = 'temp_CACHED' . $cacheFileSuffix;
                                // Setting the name for the cache files:
                        if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==1)     $cacheFilePrefix.= '_ps'.substr(t3lib_div::shortMD5(PATH_site.'|'.$GLOBALS['TYPO_VERSION']), 0, 4);
                        if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==2)     $cacheFilePrefix.= '_'.t3lib_div::shortMD5($rawExtList);
@@ -1223,8 +1235,7 @@ tt_content.'.$key.$prefix.' {
                        } else {        // ... but if not, configure...
 
                                        // Prepare reserved filenames:
-                               $files = t3lib_div::trimExplode(',', 'ext_localconf.php,ext_tables.php,ext_tables.sql,ext_tables_static+adt.sql,ext_typoscript_constants.txt,ext_typoscript_editorcfg.txt,ext_typoscript_setup.txt', 1);
-
+                               $files = array('ext_localconf.php','ext_tables.php','ext_tables.sql','ext_tables_static+adt.sql','ext_typoscript_constants.txt','ext_typoscript_editorcfg.txt','ext_typoscript_setup.txt');
                                        // Traverse extensions and check their existence:
                                clearstatcache();       // Clear file state cache to make sure we get good results from is_dir()
                                $temp_extensions = array_unique(t3lib_div::trimExplode(',', $rawExtList, 1));
@@ -1348,14 +1359,19 @@ $_EXTCONF = $TYPO3_CONF_VARS[\'EXT\'][\'extConf\'][$_EXTKEY];
         * @internal
         */
        public static function currentCacheFiles() {
-               global $TYPO3_LOADED_EXT;
-
-               if ($TYPO3_LOADED_EXT['_CACHEFILE']) {
-                       if (t3lib_extMgm::isCacheFilesAvailable($TYPO3_LOADED_EXT['_CACHEFILE'])) {
-                               return array(
-                                       PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_localconf.php',
-                                       PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_tables.php'
-                               );
+               if (($cacheFilePrefix = $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'])) {
+                       $cacheFilePrefixFE = str_replace('temp_CACHED','temp_CACHED_FE',$cacheFilePrefix);
+                       $files = array();
+                       if (t3lib_extMgm::isCacheFilesAvailable($cacheFilePrefix)) {
+                               $files[] = PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php';
+                               $files[] = PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php';
+                       }
+                       if (t3lib_extMgm::isCacheFilesAvailable($cacheFilePrefixFE)) {
+                               $files[] = PATH_typo3conf.$cacheFilePrefixFE.'_ext_localconf.php';
+                               $files[] = PATH_typo3conf.$cacheFilePrefixFE.'_ext_tables.php';
+                       }
+                       if (!empty($files)) {
+                               return $files;
                        }
                }
        }
index 5ca0904..c59b06c 100644 (file)
@@ -3958,6 +3958,8 @@ EXTENSION KEYS:
        function writeNewExtensionList($newExtList)     {
                global $TYPO3_CONF_VARS;
 
+               $strippedExtensionList = $this->stripNonFrontendExtensions($newExtList);
+
                // Instance of install tool
                $instObj = new t3lib_install;
                $instObj->allowUpdateLocalConf =1;
@@ -3966,13 +3968,34 @@ EXTENSION KEYS:
                // Get lines from localconf file
                $lines = $instObj->writeToLocalconf_control();
                $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
+               $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList_FE\']', $strippedExtensionList);
                $instObj->writeToLocalconf_control($lines);
 
                $TYPO3_CONF_VARS['EXT']['extList'] = $newExtList;
+               $TYPO3_CONF_VARS['EXT']['extList_FE'] = $strippedExtensionList;
                $this->removeCacheFiles();
        }
 
        /**
+        * Removes unneeded extensions from the frontend based on
+        * EMCONF doNotLoadInFE = 1
+        *
+        * @param string $extList
+        * @return string
+        */
+       function stripNonFrontendExtensions($extList) {
+               $fullExtList = $this->getInstalledExtensions();
+               $extListArray = t3lib_div::trimExplode(',', $extList);
+               foreach ($extListArray as $arrayKey => $extKey) {
+                       if ($fullExtList[0][$extKey]['EM_CONF']['doNotLoadInFE'] == 1) {
+                               unset($extListArray[$arrayKey]);
+                       }
+               }
+               $nonFEList = implode(',', $extListArray);
+               return $nonFEList;
+       }
+
+       /**
         * Writes the TSstyleconf values to "localconf.php"
         * Removes the temp_CACHED* files before return.
         *