From: Tim Starling Date: Mon, 10 Mar 2008 04:08:44 +0000 (+0000) Subject: Fixed Database::ping() for MySQL client 5.0.13+. X-Git-Tag: 1.31.0-rc.0~49184 X-Git-Url: http://git.cyclocoop.org/%27.%28%24current%20%3E%202?a=commitdiff_plain;h=45a998174af18c39b3deaa1163c74429fd75a329;p=lhc%2Fweb%2Fwiklou.git Fixed Database::ping() for MySQL client 5.0.13+. --- diff --git a/includes/Database.php b/includes/Database.php index f8738288e9..5863750331 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -2122,12 +2122,24 @@ class Database { * Ping the server and try to reconnect if it there is no connection */ function ping() { - if( function_exists( 'mysql_ping' ) ) { - return mysql_ping( $this->mConn ); - } else { + if( !function_exists( 'mysql_ping' ) ) { wfDebug( "Tried to call mysql_ping but this is ancient PHP version. Faking it!\n" ); return true; } + $ping = mysql_ping( $this->mConn ); + if ( $ping ) { + return true; + } + + // Need to reconnect manually in MySQL client 5.0.13+ + if ( version_compare( mysql_get_client_info(), '5.0.13', '>=' ) ) { + mysql_close( $this->mConn ); + $this->mOpened = false; + $this->mConn = false; + $this->open( $this->mServer, $this->mUser, $this->mPassword, $this->mDBname ); + return true; + } + return false; } /**