$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");
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
$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 );
}
/**