lockmanager: tweak FSLockManager permission handling in doSingleLock()
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 3 Jul 2019 10:38:48 +0000 (03:38 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 6 Jul 2019 19:46:52 +0000 (12:46 -0700)
Change-Id: Ia0070cc727ca622e127456ddb0e39d007e19f169

includes/libs/lockmanager/FSLockManager.php

index 019029c..c00b041 100644 (file)
@@ -124,9 +124,13 @@ class FSLockManager extends LockManager {
                        } else {
                                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}'." );
+                                       }
                                }
                                Wikimedia\restoreWarnings();
                        }