Merge "maintenance: Script to rename titles for Unicode uppercasing changes"
[lhc/web/wiklou.git] / includes / libs / lockmanager / FSLockManager.php
index 7f33a0a..c00b041 100644 (file)
@@ -122,13 +122,17 @@ class FSLockManager extends LockManager {
                        if ( isset( $this->handles[$path] ) ) {
                                $handle = $this->handles[$path];
                        } else {
-                               MediaWiki\suppressWarnings();
+                               Wikimedia\suppressWarnings();
                                $handle = fopen( $this->getLockPath( $path ), 'a+' );
-                               if ( !$handle ) { // lock dir missing?
-                                       mkdir( $this->lockDir, 0777, true );
-                                       $handle = fopen( $this->getLockPath( $path ), 'a+' ); // try again
+                               if ( !$handle && !is_dir( $this->lockDir ) ) {
+                                       // Create the lock directory in case it is missing
+                                       if ( mkdir( $this->lockDir, 0777, true ) ) {
+                                               $handle = fopen( $this->getLockPath( $path ), 'a+' ); // try again
+                                       } else {
+                                               $this->logger->error( "Cannot create directory '{$this->lockDir}'." );
+                                       }
                                }
-                               MediaWiki\restoreWarnings();
+                               Wikimedia\restoreWarnings();
                        }
                        if ( $handle ) {
                                // Either a shared or exclusive lock
@@ -169,7 +173,7 @@ class FSLockManager extends LockManager {
                        if ( $this->locksHeld[$path][$type] <= 0 ) {
                                unset( $this->locksHeld[$path][$type] );
                        }
-                       if ( !count( $this->locksHeld[$path] ) ) {
+                       if ( $this->locksHeld[$path] === [] ) {
                                unset( $this->locksHeld[$path] ); // no locks on this path
                                if ( isset( $this->handles[$path] ) ) {
                                        $handlesToClose[] = $this->handles[$path];