Fixed bug #17114: Install Tool does not install extensions properly
authorFrancois Suter <francois.suter@typo3.org>
Thu, 20 Jan 2011 14:12:03 +0000 (14:12 +0000)
committerFrancois Suter <francois.suter@typo3.org>
Thu, 20 Jan 2011 14:12:03 +0000 (14:12 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10157 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/install/Classes/Updates/Base.php
typo3/sysext/install/updates/class.tx_coreupdates_installnewsysexts.php
typo3/sysext/install/updates/class.tx_coreupdates_installsysexts.php

index 996aff1..75493ad 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-01-20  Francois Suter  <francois.suter@typo3.org>
+
+       * Fixed bug #17114: Install Tool does not install extensions properly
+
 2011-01-20  Susanne Moog  <typo3@susanne-moog.de>
 
        * Fixed bug #17116: All images get reduced to 25x25px upon saving if no size is set
index de17a44..d029a7b 100644 (file)
@@ -187,8 +187,38 @@ abstract class Tx_Install_Updates_Base {
                $res = $this->checkForUpdate($explanation, $showUpdate);
                return ($showUpdate != 2 || $res == TRUE);
        }
-       
 
-}
+       /**
+        * This method creates an instance of a connection to the Extension Manager
+        * and returns it. This is used when installing an extension.
+        * 
+        * @return tx_em_Connection_ExtDirectServer EM connection instance
+        */
+       public function getExtensionManagerConnection() {
+                       // Create an instance of language, if necessary.
+                       // Needed in order to make the em_index work
+               if (!isset($GLOBALS['LANG'])) {
+                       $GLOBALS['LANG'] = t3lib_div::makeInstance('language');
+                       $GLOBALS['LANG']->csConvObj = t3lib_div::makeInstance('t3lib_cs');
+               }
+                       // Create an instance of a connection class to the EM
+               $extensionManagerConnection = t3lib_div::makeInstance('tx_em_Connection_ExtDirectServer', FALSE);
+               return $extensionManagerConnection;
+       }
 
+       /**
+        * This method can be called to install extensions following all proper processes
+        * (e.g. installing in both extList and extList_FE, respecting priority, etc.)
+        *
+        * @param array $extensionKeys List of keys of extensions to install
+        * @return void
+        */
+       protected function installExtensions($extensionKeys) {
+               $extensionManagerConnection = $this->getExtensionManagerConnection();
+               foreach ($extensionKeys as $extension) {
+                       $extensionManagerConnection->enableExtension($extension);
+               }
+       }
+
+}
 ?>
index ccfb4eb..040d6c0 100644 (file)
@@ -134,19 +134,16 @@ class tx_coreupdates_installnewsysexts extends Tx_Install_Updates_Base {
         * @return      boolean         whether it worked (true) or not (false)
         */
        public function performUpdate(&$dbQueries, &$customMessages) {
-               $result = false;
+               $result = FALSE;
 
-               // Get extension keys that were submitted by the used to be installed and that are valid for this update wizard:
+                       // Get extension keys that were submitted by the user to be installed and that are valid for this update wizard
                if (is_array($this->pObj->INSTALL['update']['installNewSystemExtensions']['sysext'])) {
                        $extArray = array_intersect(
                                $this->newSystemExtensions,
                                array_keys($this->pObj->INSTALL['update']['installNewSystemExtensions']['sysext'])
                        );
-                       $extList = $this->addExtToList($extArray);
-                       if ($extList) {
-                               $this->writeNewExtensionList($extList);
-                               $result = true;
-                       }
+                       $this->installExtensions($extArray);
+                       $result = TRUE;
                }
 
                return $result;
@@ -159,8 +156,10 @@ class tx_coreupdates_installnewsysexts extends Tx_Install_Updates_Base {
         *
         * @param       array           Extension keys to add
         * @return      string          New list of installed extensions or -1 if error
+        * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7 - Should not be needed anymore. Extensions should be installed directly by calling Tx_Install_Updates_Base::installExtensions()
         */
        function addExtToList(array $extKeys) {
+               t3lib_div::logDeprecatedFunction();
                        // Get list of installed extensions and add this one.
                $tmpLoadedExt = $GLOBALS['TYPO3_LOADED_EXT'];
                if (isset($tmpLoadedExt['_CACHEFILE'])) {
@@ -181,8 +180,10 @@ class tx_coreupdates_installnewsysexts extends Tx_Install_Updates_Base {
         *
         * @param       string          List of extensions
         * @return      void
+        * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7 - Use Tx_Install_Updates_Base::installExtensions() instead
         */
-       protected function writeNewExtensionList($newExtList)   {
+       protected function writeNewExtensionList($newExtList) {
+               t3lib_div::logDeprecatedFunction();
                        // Instance of install tool
                $instObj = new t3lib_install;
                $instObj->allowUpdateLocalConf = 1;
index 18d4a6c..b0498b7 100644 (file)
@@ -179,33 +179,31 @@ class tx_coreupdates_installsysexts extends Tx_Install_Updates_Base {
         * @return      boolean         whether it worked (true) or not (false)
         */
        public function performUpdate(&$dbQueries, &$customMessages) {
-               $result = false;
+               $result = FALSE;
 
-               // Get extension keys that were submitted by the used to be installed and that are valid for this update wizard:
+                       // Get extension keys that were submitted by the user to be installed and that are valid for this update wizard
                if (is_array($this->pObj->INSTALL['update']['installSystemExtensions']['sysext'])) {
                        $extArray = array_intersect(
                                $this->newSystemExtensions,
                                array_keys($this->pObj->INSTALL['update']['installSystemExtensions']['sysext'])
                        );
-                       $extList = $this->addExtToList($extArray);
-                       if ($extList) {
-                               $this->writeNewExtensionList($extList);
-                               $result = true;
-                       }
+                       $this->installExtensions($extArray);
+                       $result = TRUE;
                }
 
                return $result;
        }
 
-
        /**
         * Adds extension to extension list and returns new list. If -1 is returned, an error happend.
         * Does NOT check dependencies yet.
         *
         * @param       array           Extension keys to add
         * @return      string          New list of installed extensions or -1 if error
+        * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7 - Should not be needed anymore. Extensions should be installed directly by calling Tx_Install_Updates_Base::installExtensions()
         */
        function addExtToList(array $extKeys) {
+               t3lib_div::logDeprecatedFunction();
                        // Get list of installed extensions and add this one.
                $tmpLoadedExt = $GLOBALS['TYPO3_LOADED_EXT'];
                if (isset($tmpLoadedExt['_CACHEFILE'])) {
@@ -226,8 +224,10 @@ class tx_coreupdates_installsysexts extends Tx_Install_Updates_Base {
         *
         * @param       string          List of extensions
         * @return      void
+        * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7 - Use Tx_Install_Updates_Base::installExtensions() instead
         */
-       protected function writeNewExtensionList($newExtList)   {
+       protected function writeNewExtensionList($newExtList) {
+               t3lib_div::logDeprecatedFunction();
                        // Instance of install tool
                $instObj = new t3lib_install;
                $instObj->allowUpdateLocalConf = 1;