Use /** for doc comments
[lhc/web/wiklou.git] / includes / db / DatabaseMysqli.php
index 635909c..b8d5d79 100644 (file)
@@ -57,6 +57,17 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                                . " have you compiled PHP with the --with-mysqli option?\n" );
                }
 
+               // Other than mysql_connect, mysqli_real_connect expects an explicit port
+               // parameter. So we need to parse the port out of $realServer
+               $port = null;
+               $hostAndPort = IP::splitHostAndPort( $realServer );
+               if ( $hostAndPort ) {
+                       $realServer = $hostAndPort[0];
+                       if ( $hostAndPort[1] ) {
+                               $port = $hostAndPort[1];
+                       }
+               }
+
                $connFlags = 0;
                if ( $this->mFlags & DBO_SSL ) {
                        $connFlags |= MYSQLI_CLIENT_SSL;
@@ -76,17 +87,12 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                } else {
                        $mysqli->options( MYSQLI_SET_CHARSET_NAME, 'binary' );
                }
+               $mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 3 );
 
-               $numAttempts = 2;
-               for ( $i = 0; $i < $numAttempts; $i++ ) {
-                       if ( $i > 1 ) {
-                               usleep( 1000 );
-                       }
-                       if ( $mysqli->real_connect( $realServer, $this->mUser,
-                               $this->mPassword, $this->mDBname, null, null, $connFlags )
-                       ) {
-                               return $mysqli;
-                       }
+               if ( $mysqli->real_connect( $realServer, $this->mUser,
+                       $this->mPassword, $this->mDBname, $port, null, $connFlags )
+               ) {
+                       return $mysqli;
                }
 
                return false;