Fixed bug #4640: Backend login impossible with MSSQL via ODBC (thanks to Felix Eckhofer)
authorXavier Perseguers <typo3@perseguers.ch>
Sun, 7 Mar 2010 22:10:32 +0000 (22:10 +0000)
committerXavier Perseguers <typo3@perseguers.ch>
Sun, 7 Mar 2010 22:10:32 +0000 (22:10 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dbal/trunk@30854 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/dbal/ChangeLog
typo3/sysext/dbal/class.ux_t3lib_db.php

index d82058e..098f693 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-07  Xavier Perseguers  <typo3@perseguers.ch>
+
+       * Fixed bug #4640: Backend login impossible with MSSQL via ODBC (thanks to Felix Eckhofer)
+
 2010-02-21  Xavier Perseguers  <typo3@perseguers.ch>
 
        * Fixed bug #2367: No support for LIMIT [PostgreSQL]
index 7c0591f..81d9a89 100644 (file)
@@ -1672,12 +1672,22 @@ class ux_t3lib_DB extends t3lib_DB {
 
                                                // Removing all numeric/integer keys.
                                                // A workaround because in ADOdb we would need to know what we want before executing the query...
+                                               // MSSQL does not support ADODB_FETCH_BOTH and always returns an assoc. array instead. So
+                                               // we don't need to remove anything.
                                        if (is_array($output)) {
-                                               foreach ($output as $key => $value) {
-                                                       if (is_integer($key)) {
-                                                               unset($output[$key]);
+                                               if ($this->runningADOdbDriver('mssql')) {
+                                                               // MSSQL does not know such thing as an empty string. So it returns one space instead, which we must fix.
+                                                       foreach ($output as $key => $value) {
+                                                               if ($value === ' ') {
+                                                                       $output[$key] = '';
+                                                               }
+                                                       }
+                                               } else {
+                                                       foreach ($output as $key => $value) {
+                                                               if (is_integer($key)) {
+                                                                       unset($output[$key]);
+                                                               }
                                                        }
-                                                       elseif ($value === ' ' && $this->runningADOdbDriver('mssql')) $output[$key] = ''; // MSSQL does not know such thing as an empty string. So it returns one space instead, which we must fix.
                                                }
                                        }
                                }
@@ -1721,10 +1731,20 @@ class ux_t3lib_DB extends t3lib_DB {
 
                                                // Removing all assoc. keys.
                                                // A workaround because in ADOdb we would need to know what we want before executing the query...
+                                               // MSSQL does not support ADODB_FETCH_BOTH and always returns an assoc. array instead. So
+                                               // we need to convert resultset.
                                        if (is_array($output)) {
+                                               $keyIndex = 0;
                                                foreach ($output as $key => $value) {
-                                                       if (!is_integer($key))  unset($output[$key]);
-                                                       elseif ($value === ' ' && $this->runningADOdbDriver('mssql')) $output[$key] = ''; // MSSQL does not know such thing as an empty string. So it returns one space instead, which we must fix.
+                                                       unset($output[$key]);
+                                                       if (is_integer($key) || $this->runningADOdbDriver('mssql')) {
+                                                               $output[$keyIndex] = $value;
+                                                               if ($value === ' ') {
+                                                                               // MSSQL does not know such thing as an empty string. So it returns one space instead, which we must fix.
+                                                                       $output[$keyIndex] = '';
+                                                               }
+                                                               $keyIndex++;
+                                                       }
                                                }
                                        }
                                }