X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdb%2FDatabaseMysql.php;h=5b15147777c68ae7034fc88783f9358874f15deb;hb=28c98539cd0fd4a1cf5e9ce7662b7a360fb64dbb;hp=823d9b67a60395498992d6dd2ec348facc9679ab;hpb=65f8b65bd37c76c5fd62b8ae6d860fb580f69dd4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index 823d9b67a6..5b15147777 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -33,10 +33,12 @@ class DatabaseMysql extends DatabaseMysqlBase { * @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; @@ -48,8 +50,7 @@ class DatabaseMysql extends DatabaseMysqlBase { * @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, @@ -73,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 ); @@ -93,8 +97,10 @@ class DatabaseMysql extends DatabaseMysqlBase { * @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__ ); } @@ -104,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 ); } /** @@ -129,7 +139,9 @@ class DatabaseMysql extends DatabaseMysqlBase { * @return int */ function affectedRows() { - return mysql_affected_rows( $this->mConn ); + $conn = $this->getBindingHandle(); + + return mysql_affected_rows( $conn ); } /** @@ -137,9 +149,11 @@ class DatabaseMysql extends DatabaseMysqlBase { * @return bool */ function selectDB( $db ) { + $conn = $this->getBindingHandle(); + $this->mDBname = $db; - return mysql_select_db( $db, $this->mConn ); + return mysql_select_db( $db, $conn ); } protected function mysqlFreeResult( $res ) { @@ -183,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 ); } }