X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdb%2FDatabaseMysql.php;h=1d03073b15406f9ef3f3fe4a8db896b5a55f138a;hb=b64452a3f72c93f706582f8ce1d4669ade0d2e73;hp=c334c388d8e354dd617ac58a1f719f1706ae38b1;hpb=78a56a67ba2a5b2834ef50fc0f4fe0db566379b6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index c334c388d8..1d03073b15 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -113,14 +113,14 @@ class DatabaseMysql extends DatabaseBase { $phpError = $this->restoreErrorHandler(); # Always log connection errors if ( !$this->mConn ) { - $error = $this->lastError(); + $error = $phpError; if ( !$error ) { - $error = $phpError; + $error = $this->lastError(); } wfLogDBError( "Error connecting to {$this->mServer}: $error\n" ); wfDebug( "DB connection error\n" ); wfDebug( "Server: $server, User: $user, Password: " . - substr( $password, 0, 3 ) . "..., error: " . mysql_error() . "\n" ); + substr( $password, 0, 3 ) . "..., error: " . $error . "\n" ); } wfProfileOut("dbconnect-$server"); @@ -686,6 +686,21 @@ class DatabaseMysql extends DatabaseBase { return parent::streamStatementEnd( $sql, $newLine ); } + /** + * Check to see if a named lock is available. This is non-blocking. + * + * @param $lockName String: name of lock to poll + * @param $method String: name of method calling us + * @return Boolean + * @since 1.20 + */ + public function lockIsFree( $lockName, $method ) { + $lockName = $this->addQuotes( $lockName ); + $result = $this->query( "SELECT IS_FREE_LOCK($lockName) AS lockstatus", $method ); + $row = $this->fetchObject( $result ); + return ( $row->lockstatus == 1 ); + } + /** * @param $lockName string * @param $method string @@ -715,7 +730,7 @@ class DatabaseMysql extends DatabaseBase { $lockName = $this->addQuotes( $lockName ); $result = $this->query( "SELECT RELEASE_LOCK($lockName) as lockstatus", $method ); $row = $this->fetchObject( $result ); - return $row->lockstatus; + return ( $row->lockstatus == 1 ); } /**