[BUGFIX] ADOdb: mssqlnative driver is not properly initialized 35/39335/2
authorXavier Perseguers <xavier@typo3.org>
Thu, 7 May 2015 10:29:01 +0000 (12:29 +0200)
committerXavier Perseguers <xavier@typo3.org>
Thu, 7 May 2015 15:10:29 +0000 (17:10 +0200)
Problems:

- Empty username/password should use Windows Authentication
- Character set is not used when connecting
- Port is not properly passed as argument

Change-Id: I7d45949dfd3dc6f8fd74033e9d39c8df80029db5
Releases: master, 6.2
Resolves: #66830
Resolves: #63070
Reviewed-on: http://review.typo3.org/39324
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Xavier Perseguers <xavier@typo3.org>
Tested-by: Xavier Perseguers <xavier@typo3.org>
Reviewed-on: http://review.typo3.org/39335

typo3/sysext/adodb/Documentation/Index.rst
typo3/sysext/adodb/Documentation/typo3-adodb.diff
typo3/sysext/adodb/adodb/drivers/adodb-mssqlnative.inc.php

index 7a4a975..8548a99 100644 (file)
@@ -20,6 +20,8 @@ updated to upstream.
 - EXT:adodb: Table names in ALTER TABLE broken (63659_)
 - MSSQL native driver for ADOdb returns erroneous message (66674_)
 - ADOdb: mssqlnative driver fails to create sequences (66678_)
+- ADOdb: mssqlnative driver is not properly initialized (66830_)
+- ADOdb: mssqlnative driver does not properly define the port (63070_)
 
 .. [2] https://github.com/ADOdb/ADOdb/commit/85f05a98974ea85ecae943faf230a27afdbaa746
 .. _48034: https://forge.typo3.org/issues/48034
@@ -27,6 +29,8 @@ updated to upstream.
 .. _63659: https://forge.typo3.org/issues/63659
 .. _66674: https://forge.typo3.org/issues/66674
 .. _66678: https://forge.typo3.org/issues/66678
+.. _66830: https://forge.typo3.org/issues/66830
+.. _63070: https://forge.typo3.org/issues/63070
 
 
 Diff
index 8bff9bc..520c47a 100644 (file)
@@ -266,3 +266,34 @@ index b10d555..21cfc69 100644
                return $this->_errorMsg;
        }
 
+@@ -476,10 +476,26 @@ class ADODB_mssqlnative extends ADOConnection {
+       function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
+       {
+               if (!function_exists('sqlsrv_connect')) return null;
++              // Port is always given as part of $argHostname but
++              // 1) should only be set if using an IP/hostname and not a named instance
++              // 2) must use a comma instead of a colon
++              list ($hostname, $port) = explode(':', $argHostname, 2);
++              if (strpos($hostname, '\\') === false) {
++                      $argHostname = $hostname . ',' . $port;
++              } else {
++                      $argHostname = $hostname;
++              }
+               $connectionInfo = $this->connectionInfo;
+-              $connectionInfo["Database"]=$argDatabasename;
+-              $connectionInfo["UID"]=$argUsername;
+-              $connectionInfo["PWD"]=$argPassword;
++              $connectionInfo['Database'] = $argDatabasename;
++              if (!empty($argUsername)) {
++                      $connectionInfo['UID'] = $argUsername;
++              }
++              if (!empty($argPassword)) {
++                      $connectionInfo['PWD'] = $argPassword;
++              }
++              if (!empty($this->charSet)) {
++                      $connectionInfo['CharacterSet'] = $this->charSet;
++              }
+               if ($this->debug) error_log("<hr>connecting... hostname: $argHostname params: ".var_export($connectionInfo,true));
+               //if ($this->debug) error_log("<hr>_connectionID before: ".serialize($this->_connectionID));
+               if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) {
+
index 8de4844..5db3f77 100644 (file)
@@ -476,10 +476,26 @@ class ADODB_mssqlnative extends ADOConnection {
        function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
        {
                if (!function_exists('sqlsrv_connect')) return null;
+               // Port is always given as part of $argHostname but
+               // 1) should only be set if using an IP/hostname and not a named instance
+               // 2) must use a comma instead of a colon
+               list ($hostname, $port) = explode(':', $argHostname, 2);
+               if (strpos($hostname, '\\') === false) {
+                       $argHostname = $hostname . ',' . $port;
+               } else {
+                       $argHostname = $hostname;
+               }
                $connectionInfo = $this->connectionInfo;
-               $connectionInfo["Database"]=$argDatabasename;
-               $connectionInfo["UID"]=$argUsername;
-               $connectionInfo["PWD"]=$argPassword;
+               $connectionInfo['Database'] = $argDatabasename;
+               if (!empty($argUsername)) {
+                       $connectionInfo['UID'] = $argUsername;
+               }
+               if (!empty($argPassword)) {
+                       $connectionInfo['PWD'] = $argPassword;
+               }
+               if (!empty($this->charSet)) {
+                       $connectionInfo['CharacterSet'] = $this->charSet;
+               }
                if ($this->debug) error_log("<hr>connecting... hostname: $argHostname params: ".var_export($connectionInfo,true));
                //if ($this->debug) error_log("<hr>_connectionID before: ".serialize($this->_connectionID));
                if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) {