Fixed infinite loop in tests with FSLockManager.
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 6 Jun 2012 05:06:56 +0000 (22:06 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 6 Jun 2012 05:07:09 +0000 (22:07 -0700)
* If PHPUnit converts warnings to exceptions, any I/O warnings can throw
exceptions which leave locksHeld in an inconsistent state, breaking the
__destruct() function. This commits reorders the variable update slightly.

Change-Id: I5deac811e7b4d0bc71f3d4096b8d72711904a444

includes/filerepo/backend/lockmanager/FSLockManager.php

index 2b727a8..53f3e9f 100644 (file)
@@ -176,6 +176,9 @@ class FSLockManager extends LockManager {
                                        unset( $this->handles[$path][$type] );
                                }
                        }
+                       if ( !count( $this->locksHeld[$path] ) ) {
+                               unset( $this->locksHeld[$path] ); // no locks on this path
+                       }
                        // Unlock handles to release locks and delete
                        // any lock files that end up with no locks on them...
                        if ( wfIsWindows() ) {
@@ -218,12 +221,11 @@ class FSLockManager extends LockManager {
         */
        private function pruneKeyLockFiles( $path ) {
                $status = Status::newGood();
-               if ( !count( $this->locksHeld[$path] ) ) {
+               if ( !isset( $this->locksHeld[$path] ) ) {
                        # No locks are held for the lock file anymore
                        if ( !unlink( $this->getLockPath( $path ) ) ) {
                                $status->warning( 'lockmanager-fail-deletelock', $path );
                        }
-                       unset( $this->locksHeld[$path] );
                        unset( $this->handles[$path] );
                }
                return $status;