Merge "(bug 36819) Lowercase be,csb,cu,dsb,hsb,rue,sgs,szl"
[lhc/web/wiklou.git] / includes / db / DatabaseMysql.php
index c334c38..1d03073 100644 (file)
@@ -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 );
        }
 
        /**