From: Aaron Schulz Date: Wed, 6 Jun 2012 05:06:56 +0000 (-0700) Subject: Fixed infinite loop in tests with FSLockManager. X-Git-Tag: 1.31.0-rc.0~23390 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=commitdiff_plain;h=47de3d2aec5c054ece96bb82fb358336b432232f;p=lhc%2Fweb%2Fwiklou.git Fixed infinite loop in tests with FSLockManager. * 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 --- diff --git a/includes/filerepo/backend/lockmanager/FSLockManager.php b/includes/filerepo/backend/lockmanager/FSLockManager.php index 2b727a8fd3..53f3e9f974 100644 --- a/includes/filerepo/backend/lockmanager/FSLockManager.php +++ b/includes/filerepo/backend/lockmanager/FSLockManager.php @@ -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;