Code Duplication    Length = 14-14 lines in 3 locations

includes/db/DatabasePostgres.php 1 location

@@ 1606-1619 (lines=14) @@
1603
	 * @param string $method
1604
	 * @return bool
1605
	 */
1606
	public function unlock( $lockName, $method ) {
1607
		$key = $this->addQuotes( $this->bigintFromLockName( $lockName ) );
1608
		$result = $this->query( "SELECT pg_advisory_unlock($key) as lockstatus", $method );
1609
		$row = $this->fetchObject( $result );
1610
1611
		if ( $row->lockstatus === 't' ) {
1612
			parent::unlock( $lockName, $method ); // record
1613
			return true;
1614
		}
1615
1616
		wfDebug( __METHOD__ . " failed to release lock\n" );
1617
1618
		return false;
1619
	}
1620
1621
	/**
1622
	 * @param string $lockName

includes/db/DatabaseMysqlBase.php 2 locations

@@ 982-995 (lines=14) @@
979
	 * @param int $timeout
980
	 * @return bool
981
	 */
982
	public function lock( $lockName, $method, $timeout = 5 ) {
983
		$lockName = $this->addQuotes( $this->makeLockName( $lockName ) );
984
		$result = $this->query( "SELECT GET_LOCK($lockName, $timeout) AS lockstatus", $method );
985
		$row = $this->fetchObject( $result );
986
987
		if ( $row->lockstatus == 1 ) {
988
			parent::lock( $lockName, $method, $timeout ); // record
989
			return true;
990
		}
991
992
		wfDebug( __METHOD__ . " failed to acquire lock\n" );
993
994
		return false;
995
	}
996
997
	/**
998
	 * FROM MYSQL DOCS:
@@ 1004-1017 (lines=14) @@
1001
	 * @param string $method
1002
	 * @return bool
1003
	 */
1004
	public function unlock( $lockName, $method ) {
1005
		$lockName = $this->addQuotes( $this->makeLockName( $lockName ) );
1006
		$result = $this->query( "SELECT RELEASE_LOCK($lockName) as lockstatus", $method );
1007
		$row = $this->fetchObject( $result );
1008
1009
		if ( $row->lockstatus == 1 ) {
1010
			parent::unlock( $lockName, $method ); // record
1011
			return true;
1012
		}
1013
1014
		wfDebug( __METHOD__ . " failed to release lock\n" );
1015
1016
		return false;
1017
	}
1018
1019
	private function makeLockName( $lockName ) {
1020
		// http://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock