From 47de3d2aec5c054ece96bb82fb358336b432232f Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 5 Jun 2012 22:06:56 -0700 Subject: [PATCH] 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 --- includes/filerepo/backend/lockmanager/FSLockManager.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; -- 2.20.1