X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdb%2FDatabaseMysql.php;h=b600d9484693005a7d3e3f688694c98be3e9e29a;hb=16f707477caa2315279570553d7f10b43b8e6911;hp=e253f91dd9174f20813076db101222b3095bdc93;hpb=d459c2afb3928ceea157aa0eaa5230335cbc06ec;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index e253f91dd9..5b15147777 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -29,22 +29,28 @@ */ class DatabaseMysql extends DatabaseMysqlBase { /** - * @param $sql string - * @return resource + * @param string $sql + * @return resource False on error */ protected function doQuery( $sql ) { + $conn = $this->getBindingHandle(); + if ( $this->bufferResults() ) { - $ret = mysql_query( $sql, $this->mConn ); + $ret = mysql_query( $sql, $conn ); } else { - $ret = mysql_unbuffered_query( $sql, $this->mConn ); + $ret = mysql_unbuffered_query( $sql, $conn ); } return $ret; } + /** + * @param string $realServer + * @return bool|resource MySQL Database connection or false on failure to connect + * @throws DBConnectionError + */ protected function mysqlConnect( $realServer ) { - # Fail now - # Otherwise we get a suppressed fatal error, which is very hard to track down + # Avoid a suppressed fatal error, which is very hard to track down if ( !extension_loaded( 'mysql' ) ) { throw new DBConnectionError( $this, @@ -68,6 +74,9 @@ class DatabaseMysql extends DatabaseMysqlBase { $conn = false; + # The kernel's default SYN retransmission period is far too slow for us, + # so we use a short timeout plus a manual retry. Retrying means that a small + # but finite rate of SYN packet loss won't cause user-visible errors. for ( $i = 0; $i < $numAttempts && !$conn; $i++ ) { if ( $i > 1 ) { usleep( 1000 ); @@ -84,11 +93,14 @@ class DatabaseMysql extends DatabaseMysqlBase { } /** + * @param string $charset * @return bool */ protected function mysqlSetCharset( $charset ) { + $conn = $this->getBindingHandle(); + if ( function_exists( 'mysql_set_charset' ) ) { - return mysql_set_charset( $charset, $this->mConn ); + return mysql_set_charset( $charset, $conn ); } else { return $this->query( 'SET NAMES ' . $charset, __METHOD__ ); } @@ -98,14 +110,18 @@ class DatabaseMysql extends DatabaseMysqlBase { * @return bool */ protected function closeConnection() { - return mysql_close( $this->mConn ); + $conn = $this->getBindingHandle(); + + return mysql_close( $conn ); } /** * @return int */ function insertId() { - return mysql_insert_id( $this->mConn ); + $conn = $this->getBindingHandle(); + + return mysql_insert_id( $conn ); } /** @@ -123,24 +139,21 @@ class DatabaseMysql extends DatabaseMysqlBase { * @return int */ function affectedRows() { - return mysql_affected_rows( $this->mConn ); + $conn = $this->getBindingHandle(); + + return mysql_affected_rows( $conn ); } /** - * @param $db + * @param string $db * @return bool */ function selectDB( $db ) { - $this->mDBname = $db; + $conn = $this->getBindingHandle(); - return mysql_select_db( $db, $this->mConn ); - } + $this->mDBname = $db; - /** - * @return string - */ - function getServerVersion() { - return mysql_get_server_info( $this->mConn ); + return mysql_select_db( $db, $conn ); } protected function mysqlFreeResult( $res ) { @@ -171,6 +184,10 @@ class DatabaseMysql extends DatabaseMysqlBase { return mysql_field_name( $res, $n ); } + protected function mysqlFieldType( $res, $n ) { + return mysql_field_type( $res, $n ); + } + protected function mysqlDataSeek( $res, $row ) { return mysql_data_seek( $res, $row ); } @@ -180,10 +197,14 @@ class DatabaseMysql extends DatabaseMysqlBase { } protected function mysqlRealEscapeString( $s ) { - return mysql_real_escape_string( $s, $this->mConn ); + $conn = $this->getBindingHandle(); + + return mysql_real_escape_string( $s, $conn ); } protected function mysqlPing() { - return mysql_ping( $this->mConn ); + $conn = $this->getBindingHandle(); + + return mysql_ping( $conn ); } }