*/
class MemcLockManager extends QuorumLockManager {
/** @var array Mapping of lock types to the type actually used */
- protected $lockTypeMap = array(
+ protected $lockTypeMap = [
self::LOCK_SH => self::LOCK_SH,
self::LOCK_UW => self::LOCK_SH,
self::LOCK_EX => self::LOCK_EX
- );
+ ];
/** @var array Map server names to MemcachedBagOStuff objects */
- protected $bagOStuffs = array();
+ protected $bagOStuffs = [];
/** @var array (server name => bool) */
- protected $serversUp = array();
+ protected $serversUp = [];
/** @var string Random UUID */
protected $session = '';
$memcConfig = isset( $config['memcConfig'] )
? $config['memcConfig']
- : array( 'class' => 'MemcachedPhpBagOStuff' );
+ : [ 'class' => 'MemcachedPhpBagOStuff' ];
foreach ( $config['lockServers'] as $name => $address ) {
- $params = array( 'servers' => array( $address ) ) + $memcConfig;
+ $params = [ 'servers' => [ $address ] ] + $memcConfig;
$cache = ObjectCache::newFromParams( $params );
if ( $cache instanceof MemcachedBagOStuff ) {
$this->bagOStuffs[$name] = $cache;
protected function getLocksOnServer( $lockSrv, array $pathsByType ) {
$status = Status::newGood();
- $lockedPaths = array();
+ $lockedPaths = [];
foreach ( $pathsByType as $type => $paths ) {
$status->merge( $this->doGetLocksOnServer( $lockSrv, $paths, $type ) );
if ( $status->isOK() ) {
$status = Status::newGood();
$memc = $this->getCache( $lockSrv );
- $keys = array_map( array( $this, 'recordKeyForPath' ), $paths ); // lock records
+ $keys = array_map( [ $this, 'recordKeyForPath' ], $paths ); // lock records
// Lock all of the active lock record keys...
if ( !$this->acquireMutexes( $memc, $keys ) ) {
$status = Status::newGood();
$memc = $this->getCache( $lockSrv );
- $keys = array_map( array( $this, 'recordKeyForPath' ), $paths ); // lock records
+ $keys = array_map( [ $this, 'recordKeyForPath' ], $paths ); // lock records
// Lock all of the active lock record keys...
if ( !$this->acquireMutexes( $memc, $keys ) ) {
* @return string
*/
protected function recordKeyForPath( $path ) {
- return implode( ':', array( __CLASS__, 'locks', $this->sha1Base36Absolute( $path ) ) );
+ return implode( ':', [ __CLASS__, 'locks', $this->sha1Base36Absolute( $path ) ] );
}
/**
* @return array An empty lock structure for a key
*/
protected static function newLockArray() {
- return array( self::LOCK_SH => array(), self::LOCK_EX => array() );
+ return [ self::LOCK_SH => [], self::LOCK_EX => [] ];
}
/**
* @return bool
*/
protected function acquireMutexes( MemcachedBagOStuff $memc, array $keys ) {
- $lockedKeys = array();
+ $lockedKeys = [];
// Acquire the keys in lexicographical order, to avoid deadlock problems.
// If P1 is waiting to acquire a key P2 has, P2 can't also be waiting for a key P1 has.
function __destruct() {
while ( count( $this->locksHeld ) ) {
foreach ( $this->locksHeld as $path => $locks ) {
- $this->doUnlock( array( $path ), self::LOCK_EX );
- $this->doUnlock( array( $path ), self::LOCK_SH );
+ $this->doUnlock( [ $path ], self::LOCK_EX );
+ $this->doUnlock( [ $path ], self::LOCK_SH );
}
}
}