Merge "Set autofocus on Special:Unblock"
[lhc/web/wiklou.git] / includes / db / DatabaseMysqli.php
index 0dc1890..b8d5d79 100644 (file)
@@ -67,7 +67,7 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                                $port = $hostAndPort[1];
                        }
                }
-               
+
                $connFlags = 0;
                if ( $this->mFlags & DBO_SSL ) {
                        $connFlags |= MYSQLI_CLIENT_SSL;
@@ -87,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, $port, null, $connFlags )
-                       ) {
-                               return $mysqli;
-                       }
+               if ( $mysqli->real_connect( $realServer, $this->mUser,
+                       $this->mPassword, $this->mDBname, $port, null, $connFlags )
+               ) {
+                       return $mysqli;
                }
 
                return false;
@@ -255,6 +250,7 @@ class DatabaseMysqli extends DatabaseMysqlBase {
         */
        protected function mysqlFieldType( $res, $n ) {
                $field = $res->fetch_field_direct( $n );
+
                return $field->type;
        }
 
@@ -291,4 +287,18 @@ class DatabaseMysqli extends DatabaseMysqlBase {
        protected function mysqlPing() {
                return $this->mConn->ping();
        }
+
+       /**
+        * Give an id for the connection
+        *
+        * mysql driver used resource id, but mysqli objects cannot be cast to string.
+        */
+       public function __toString() {
+               if ( $this->mConn instanceof Mysqli ) {
+                       return (string)$this->mConn->thread_id;
+               } else {
+                       // mConn might be false or something.
+                       return (string)$this->mConn;
+               }
+       }
 }