rdbms: ignore DBO_NOBUFFER flag in IDatabase
[lhc/web/wiklou.git] / includes / libs / rdbms / database / DatabaseMysqli.php
index 0f444cd..2f9abcf 100644 (file)
@@ -40,28 +40,20 @@ class DatabaseMysqli extends DatabaseMysqlBase {
         * @return mysqli_result|bool
         */
        protected function doQuery( $sql ) {
-               $conn = $this->getBindingHandle();
-
-               if ( $this->bufferResults() ) {
-                       $ret = $conn->query( $sql );
-               } else {
-                       $ret = $conn->query( $sql, MYSQLI_USE_RESULT );
-               }
-
-               return $ret;
+               return $this->getBindingHandle()->query( $sql );
        }
 
        /**
         * @param string $realServer
         * @param string|null $dbName
-        * @return bool|mysqli
+        * @return mysqli|null
         * @throws DBConnectionError
         */
        protected function mysqlConnect( $realServer, $dbName ) {
-               # Avoid suppressed fatal error, which is very hard to track down
                if ( !function_exists( 'mysqli_init' ) ) {
-                       throw new DBConnectionError( $this, "MySQLi functions missing,"
-                               . " have you compiled PHP with the --with-mysqli option?\n" );
+                       throw $this->newExceptionAfterConnectError(
+                               "MySQLi functions missing, have you compiled PHP with the --with-mysqli option?"
+                       );
                }
 
                // Other than mysql_connect, mysqli_real_connect expects an explicit port
@@ -82,9 +74,11 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                }
 
                $mysqli = mysqli_init();
-
-               $connFlags = 0;
-               if ( $this->flags & self::DBO_SSL ) {
+               // Make affectedRows() for UPDATE reflect the number of matching rows, regardless
+               // of whether any column values changed. This is what callers want to know and is
+               // consistent with what Postgres, SQLite, and SQL Server return.
+               $connFlags = MYSQLI_CLIENT_FOUND_ROWS;
+               if ( $this->getFlag( self::DBO_SSL ) ) {
                        $connFlags |= MYSQLI_CLIENT_SSL;
                        $mysqli->ssl_set(
                                $this->sslKeyPath,
@@ -94,10 +88,10 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                                $this->sslCiphers
                        );
                }
-               if ( $this->flags & self::DBO_COMPRESS ) {
+               if ( $this->getFlag( self::DBO_COMPRESS ) ) {
                        $connFlags |= MYSQLI_CLIENT_COMPRESS;
                }
-               if ( $this->flags & self::DBO_PERSISTENT ) {
+               if ( $this->getFlag( self::DBO_PERSISTENT ) ) {
                        $realServer = 'p:' . $realServer;
                }
 
@@ -122,7 +116,7 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                        return $mysqli;
                }
 
-               return false;
+               return null;
        }
 
        /**