- Added code to deactivate DBAL if not needed
authorXavier Perseguers <typo3@perseguers.ch>
Fri, 30 Apr 2010 12:42:43 +0000 (12:42 +0000)
committerXavier Perseguers <typo3@perseguers.ch>
Fri, 30 Apr 2010 12:42:43 +0000 (12:42 +0000)
- Reflected change in hook names in Install Tool

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dbal/trunk@32778 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/dbal/class.tx_dbal_autoloader.php
typo3/sysext/dbal/class.tx_dbal_installtool.php
typo3/sysext/dbal/class.ux_t3lib_db.php
typo3/sysext/dbal/ext_localconf.php

index dfca20a..799b8f0 100644 (file)
@@ -41,18 +41,23 @@ class tx_dbal_autoloader {
        /**
         * Activates DBAL if it is supported.
         *
-        * @param integer $step
+        * @param tx_install $instObj
         * @return void
         */
-       public function execute($step) {
-               t3lib_div::debug($step, 'current step');
-               switch ($step) {
+       public function execute(tx_install $instObj) {
+               switch ($instObj->step) {
                        case 1:
+                       case 2:
                                if (!t3lib_extMgm::isLoaded('dbal') && $this->isDbalSupported()) {
-                                       t3lib_div::debug('activated dbal');
                                        $this->activateDbal();
                                }
                                break;
+                       case 3:
+                               $driver = $instObj->INSTALL['localconf.php']['typo_db_driver'];
+                               if ($driver === 'mysql' || $driver === 'mysqli') {
+                                       $this->deactivateDbal();
+                               }
+                               break;
                }
        }
 
@@ -84,6 +89,27 @@ class tx_dbal_autoloader {
        }
 
        /**
+        * Dectivates DBAL.
+        *
+        * @return void
+        */
+       protected function deactivateDbal() {
+               $extList = t3lib_div::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList']);
+               $extList = array_flip($extList);
+
+                       // Remove sysext dbal and adodb
+               if (isset($extList['dbal'])) {
+                       unset($extList['dbal']);
+               }
+               if (isset($extList['adodb'])) {
+                       unset($extList['adodb']);
+               }
+               $extList = array_flip($extList);
+
+               $this->updateExtensionList(implode(',', $extList));
+       }
+
+       /**
         * Updates the list of extensions.
         *
         * @param string $newExtList
@@ -114,9 +140,7 @@ if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/cl
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/class.tx_dbal_autoloader.php']);
 }
 
-$installStep = $this->step;
-
        // Make instance:
 $SOBE = t3lib_div::makeInstance('tx_dbal_autoloader');
-$SOBE->execute($installStep);
+$SOBE->execute($this);
 ?>
\ No newline at end of file
index 23ebfc6..e2f000e 100644 (file)
@@ -87,8 +87,13 @@ class tx_dbal_installtool {
         * @param tx_install $instObj
         * @return void
         */
-       public function executeLocalconf(array &$lines, $step, tx_install $instObj) {
+       public function executeWriteLocalconf(array &$lines, $step, tx_install $instObj) {
                switch ($step) {
+                       //case 2:
+                       //      if (isset($instObj->INSTALL['localconf.php']['typo_db_driver'])) {
+                       //              $instObj->setValueInLocalconfFile($lines, '$typo_db_driver', trim($this->INSTALL['localconf.php']['typo_db_driver']));
+                       //      }
+                       //      break;
                        case 3:
                                $driver = $instObj->INSTALL['localconf.php']['typo_db_driver'];
                                $driverConfig = '';
index 19e6dac..32ed7d9 100644 (file)
@@ -2108,10 +2108,14 @@ class ux_t3lib_DB extends t3lib_DB {
                                }
                                break;
                        case 'adodb':
-                               $sqlTables = $this->handlerInstance['_DEFAULT']->MetaTables('TABLES');
-                               while (list($k, $theTable) = each($sqlTables)) {
-                                       if (preg_match('/BIN\$/', $theTable)) continue; // skip tables from the Oracle 10 Recycle Bin
-                                       $whichTables[$theTable] = $theTable;
+                                       // check needed for install tool - otherwise it will just die because the call to
+                                       // MetaTables is done on a stdClass instance
+                               if (method_exists($this->handlerInstance['_DEFAULT'], 'MetaTables')) {
+                                       $sqlTables = $this->handlerInstance['_DEFAULT']->MetaTables('TABLES');
+                                       while (list($k, $theTable) = each($sqlTables)) {
+                                               if (preg_match('/BIN\$/', $theTable)) continue; // skip tables from the Oracle 10 Recycle Bin
+                                               $whichTables[$theTable] = $theTable;
+                                       }
                                }
                                break;
                        case 'userdefined':
index 5742860..925f9da 100644 (file)
@@ -9,5 +9,5 @@ $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc'] = t3lib_
 
 // Register a hook for the installer
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['stepOutput'][] = 'EXT:dbal/class.tx_dbal_installtool.php:tx_dbal_installtool';
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['localconf'][] = 'EXT:dbal/class.tx_dbal_installtool.php:tx_dbal_installtool';
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['writeLocalconf'][] = 'EXT:dbal/class.tx_dbal_installtool.php:tx_dbal_installtool';
 ?>