MediaWiki  1.23.2
ScopedLock.php
Go to the documentation of this file.
1 <?php
34 class ScopedLock {
36  protected $manager;
37 
39  protected $status;
40 
42  protected $pathsByType;
43 
50  $this->manager = $manager;
51  $this->pathsByType = $pathsByType;
52  $this->status = $status;
53  }
54 
69  public static function factory(
70  LockManager $manager, array $paths, $type, Status $status, $timeout = 0
71  ) {
72  $pathsByType = is_integer( $type ) ? array( $type => $paths ) : $paths;
73  $lockStatus = $manager->lockByType( $pathsByType, $timeout );
74  $status->merge( $lockStatus );
75  if ( $lockStatus->isOK() ) {
76  return new self( $manager, $pathsByType, $status );
77  }
78 
79  return null;
80  }
81 
90  public static function release( ScopedLock &$lock = null ) {
91  $lock = null;
92  }
93 
97  function __destruct() {
98  $wasOk = $this->status->isOK();
99  $this->status->merge( $this->manager->unlockByType( $this->pathsByType ) );
100  if ( $wasOk ) {
101  // Make sure status is OK, despite any unlockFiles() fatals
102  $this->status->setResult( true, $this->status->value );
103  }
104  }
105 }
LockManager
Class for handling resource locking.
Definition: LockManager.php:45
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ScopedLock
Self-releasing locks.
Definition: ScopedLock.php:34
Status\merge
merge( $other, $overwriteValue=false)
Merge another status object into this one.
Definition: Status.php:325
ScopedLock\$manager
LockManager $manager
Definition: ScopedLock.php:35
ScopedLock\release
static release(ScopedLock &$lock=null)
Release a scoped lock and set any errors in the attatched Status object.
Definition: ScopedLock.php:87
ScopedLock\$pathsByType
array $pathsByType
Map of lock types to resource paths *.
Definition: ScopedLock.php:39
ScopedLock\$status
Status $status
Definition: ScopedLock.php:37
Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: Status.php:40
ScopedLock\__construct
__construct(LockManager $manager, array $pathsByType, Status $status)
Definition: ScopedLock.php:46
ScopedLock\__destruct
__destruct()
Release the locks when this goes out of scope.
Definition: ScopedLock.php:94
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
ScopedLock\factory
static factory(LockManager $manager, array $paths, $type, Status $status, $timeout=0)
Get a ScopedLock object representing a lock on resource paths.
Definition: ScopedLock.php:66
LockManager\lockByType
lockByType(array $pathsByType, $timeout=0)
Lock the resources at the given abstract paths.
Definition: LockManager.php:102
$type
$type
Definition: testCompression.php:46