$sql = mb_convert_encoding( $sql, 'UTF-8' );
}
// Clear previously left over PQresult
- while ( $res = pg_get_result( $this->mConn ) )
+ while ( $res = pg_get_result( $this->mConn ) ) {
pg_free_result( $res );
+ }
if ( pg_send_query( $this->mConn, $sql ) === false ) {
throw new DBUnexpectedError( $this, "Unable to post new query to PostgreSQL\n" );
}
"SELECT pg_try_advisory_lock($key) AS lockstatus", $method );
$row = $this->fetchObject( $result );
if ( $row->lockstatus === 't' ) {
+ parent::lock( $lockName, $method, $timeout ); // record
return true;
} else {
sleep( 1 );
}
}
+
wfDebug( __METHOD__ . " failed to acquire lock\n" );
return false;
$result = $this->query( "SELECT pg_advisory_unlock($key) as lockstatus", $method );
$row = $this->fetchObject( $result );
- return ( $row->lockstatus === 't' );
+ if ( $row->lockstatus === 't' ) {
+ parent::unlock( $lockName, $method ); // record
+ return true;
+ }
+
+ wfDebug( __METHOD__ . " failed to release lock\n" );
+
+ return false;
}
/**
* @return string Integer
*/
private function bigintFromLockName( $lockName ) {
- return wfBaseConvert( substr( sha1( $lockName ), 0, 15 ), 16, 10 );
+ return Wikimedia\base_convert( substr( sha1( $lockName ), 0, 15 ), 16, 10 );
}
} // end DatabasePostgres class