X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdb%2FDatabaseMysqli.php;h=e46860116d49f3e3cb3d0393311f7974d24108f8;hb=2f90b6f00a3bf4fd3686538d33475063754ea349;hp=d2b5ecb1cf6083165580ccf5984e618a7c0088bc;hpb=f1fe405e9049d2dea95b16490d297e7f8a0a9c7b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/DatabaseMysqli.php b/includes/db/DatabaseMysqli.php index d2b5ecb1cf..e46860116d 100644 --- a/includes/db/DatabaseMysqli.php +++ b/includes/db/DatabaseMysqli.php @@ -29,15 +29,20 @@ * @see Database */ class DatabaseMysqli extends DatabaseMysqlBase { + /** @var mysqli */ + protected $mConn; + /** * @param string $sql * @return resource */ protected function doQuery( $sql ) { + $conn = $this->getBindingHandle(); + if ( $this->bufferResults() ) { - $ret = $this->mConn->query( $sql ); + $ret = $conn->query( $sql ); } else { - $ret = $this->mConn->query( $sql, MYSQLI_USE_RESULT ); + $ret = $conn->query( $sql, MYSQLI_USE_RESULT ); } return $ret; @@ -50,8 +55,8 @@ class DatabaseMysqli extends DatabaseMysqlBase { */ protected function mysqlConnect( $realServer ) { global $wgDBmysql5; - # Fail now - # Otherwise we get a suppressed fatal error, which is very hard to track down + + # 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" ); @@ -76,9 +81,18 @@ class DatabaseMysqli extends DatabaseMysqlBase { $socket = $hostAndSocket[1]; } + $mysqli = mysqli_init(); + $connFlags = 0; if ( $this->mFlags & DBO_SSL ) { $connFlags |= MYSQLI_CLIENT_SSL; + $mysqli->ssl_set( + $this->sslKeyPath, + $this->sslCertPath, + null, + $this->sslCAPath, + $this->sslCiphers + ); } if ( $this->mFlags & DBO_COMPRESS ) { $connFlags |= MYSQLI_CLIENT_COMPRESS; @@ -87,7 +101,6 @@ class DatabaseMysqli extends DatabaseMysqlBase { $realServer = 'p:' . $realServer; } - $mysqli = mysqli_init(); if ( $wgDBmysql5 ) { // Tell the server we're communicating with it in UTF-8. // This may engage various charset conversions. @@ -116,8 +129,10 @@ class DatabaseMysqli extends DatabaseMysqlBase { * @return bool */ protected function mysqlSetCharset( $charset ) { - if ( method_exists( $this->mConn, 'set_charset' ) ) { - return $this->mConn->set_charset( $charset ); + $conn = $this->getBindingHandle(); + + if ( method_exists( $conn, 'set_charset' ) ) { + return $conn->set_charset( $charset ); } else { return $this->query( 'SET NAMES ' . $charset, __METHOD__ ); } @@ -127,14 +142,18 @@ class DatabaseMysqli extends DatabaseMysqlBase { * @return bool */ protected function closeConnection() { - return $this->mConn->close(); + $conn = $this->getBindingHandle(); + + return $conn->close(); } /** * @return int */ function insertId() { - return (int)$this->mConn->insert_id; + $conn = $this->getBindingHandle(); + + return (int)$conn->insert_id; } /** @@ -152,7 +171,9 @@ class DatabaseMysqli extends DatabaseMysqlBase { * @return int */ function affectedRows() { - return $this->mConn->affected_rows; + $conn = $this->getBindingHandle(); + + return $conn->affected_rows; } /** @@ -160,9 +181,11 @@ class DatabaseMysqli extends DatabaseMysqlBase { * @return bool */ function selectDB( $db ) { + $conn = $this->getBindingHandle(); + $this->mDBname = $db; - return $this->mConn->select_db( $db ); + return $conn->select_db( $db ); } /** @@ -289,11 +312,9 @@ class DatabaseMysqli extends DatabaseMysqlBase { * @return string */ protected function mysqlRealEscapeString( $s ) { - return $this->mConn->real_escape_string( $s ); - } + $conn = $this->getBindingHandle(); - protected function mysqlPing() { - return $this->mConn->ping(); + return $conn->real_escape_string( $s ); } /** @@ -303,7 +324,7 @@ class DatabaseMysqli extends DatabaseMysqlBase { * @return string */ public function __toString() { - if ( $this->mConn instanceof Mysqli ) { + if ( $this->mConn instanceof mysqli ) { return (string)$this->mConn->thread_id; } else { // mConn might be false or something.