Fixed bug #14265: Driver dropdown in install tool should be hidden when only MySQL...
authorXavier Perseguers <typo3@perseguers.ch>
Sat, 1 May 2010 16:57:36 +0000 (16:57 +0000)
committerXavier Perseguers <typo3@perseguers.ch>
Sat, 1 May 2010 16:57:36 +0000 (16:57 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dbal/trunk@32841 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/dbal/ChangeLog
typo3/sysext/dbal/class.tx_dbal_autoloader.php
typo3/sysext/dbal/class.tx_dbal_installtool.php

index 94c2451..6d8dc54 100644 (file)
@@ -1,3 +1,7 @@
+2010-05-01  Xavier Perseguers  <typo3@perseguers.ch>
+
+       * Fixed bug #14265: Driver dropdown in install tool should be hidden when only MySQL is available
+
 2010-04-29  Xavier Perseguers  <typo3@perseguers.ch>
 
        * Added autoloader for Install Tool
index 799b8f0..1a00ff1 100644 (file)
@@ -54,7 +54,7 @@ class tx_dbal_autoloader {
                                break;
                        case 3:
                                $driver = $instObj->INSTALL['localconf.php']['typo_db_driver'];
-                               if ($driver === 'mysql' || $driver === 'mysqli') {
+                               if ($driver === 'mysql') {
                                        $this->deactivateDbal();
                                }
                                break;
index 219386e..0c8cc91 100644 (file)
@@ -104,7 +104,6 @@ class tx_dbal_installtool {
                                                $driverConfig = '\'useNameQuote\' => TRUE';
                                                break;
                                        case 'mysql':
-                                       case 'mysqli':
                                                return;
                                }
                                $config = 'array(' .
@@ -130,6 +129,11 @@ class tx_dbal_installtool {
         * @return void
         */
        protected function createConnectionForm($driver, array &$markers, tx_install $instObj) {
+                       // Normalize current driver
+               if (!$driver) {  
+                       $driver = $this->getDefaultDriver();
+               }
+
                        // Get the template file
                $templateFile = @file_get_contents(
                        t3lib_extMgm::extPath('dbal') . $this->templateFilePath . 'install.html'
@@ -143,21 +147,25 @@ class tx_dbal_installtool {
                $formSubPart = t3lib_parsehtml::getSubpart(
                        $template, '###CONNECTION_FORM###'
                );
-               $driverTemplate = t3lib_parsehtml::getSubpart(
-                       $formSubPart, '###DATABASE_DRIVER###'
-               );
-               $driverSubPart = $this->prepareDatabaseDrivers($driverTemplate);
+               if ($this->getNumberOfAvailableDrivers() == 1 && $this->getDefaultDriver() === 'mysql') {
+                               // Only MySQL is actually available (PDO support may be compiled in
+                               // PHP itself and as such DBAL was activated, behaves as if DBAL were
+                               // not activated
+                       $driverSubPart = '';
+               } else {
+                       $driverTemplate = t3lib_parsehtml::getSubpart(
+                               $formSubPart, '###DATABASE_DRIVER###'
+                       );
+                       $driverSubPart = $this->prepareDatabaseDrivers($driverTemplate);
+               }
                $formSubPart = t3lib_parsehtml::substituteSubpart(
                        $formSubPart,
                        '###DATABASE_DRIVER###',
                        $driverSubPart
                );
 
-               if (!$driver) {  
-                       $driver = $this->getDefaultDriver();
-               }
                        // Get the subpart related to selected database driver
-               if ($driver === '' || $driver === 'mysql' || $driver === 'mysqli') {
+               if ($driver === '' || $driver === 'mysql') {
                        $driverOptionsSubPart = t3lib_parsehtml::getSubpart(
                                $template, '###DRIVER_MYSQL###'
                        );
@@ -385,6 +393,19 @@ class tx_dbal_installtool {
        }
 
        /**
+        * Returns the number of available drivers.
+        *
+        * @return boolean
+        */
+       protected function getNumberOfAvailableDrivers() {
+               $count = 0;
+               foreach ($this->availableDrivers as $drivers) {
+                       $count += count($drivers);
+               }
+               return $count;
+       }
+
+       /**
         * Returns the driver that is selected by default in the
         * Install Tool dropdown list.
         *