X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Flockmanager%2FNullLockManager.php;h=339a7ee43a455c6d819d4d8215b06443f9f049d7;hb=4549aabaec52cdb870fed9f8e735901199ac4832;hp=b83462c7984dc56a13675f2334edd682b7b8cdc5;hpb=25d765c4735346f5207037c6f939709509013601;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/lockmanager/NullLockManager.php b/includes/libs/lockmanager/NullLockManager.php index b83462c798..339a7ee43a 100644 --- a/includes/libs/lockmanager/NullLockManager.php +++ b/includes/libs/lockmanager/NullLockManager.php @@ -22,15 +22,38 @@ */ /** - * Simple version of LockManager that does nothing + * Simple version of LockManager that only does lock reference counting * @since 1.19 */ class NullLockManager extends LockManager { protected function doLock( array $paths, $type ) { + foreach ( $paths as $path ) { + if ( isset( $this->locksHeld[$path][$type] ) ) { + ++$this->locksHeld[$path][$type]; + } else { + $this->locksHeld[$path][$type] = 1; + } + } + return StatusValue::newGood(); } protected function doUnlock( array $paths, $type ) { - return StatusValue::newGood(); + $status = StatusValue::newGood(); + + foreach ( $paths as $path ) { + if ( isset( $this->locksHeld[$path][$type] ) ) { + if ( --$this->locksHeld[$path][$type] <= 0 ) { + unset( $this->locksHeld[$path][$type] ); + if ( !$this->locksHeld[$path] ) { + unset( $this->locksHeld[$path] ); // clean up + } + } + } else { + $status->warning( 'lockmanager-notlocked', $path ); + } + } + + return $status; } }