From 0b64fdaf75f69a1abdaf79694bc96b83a7419e1e Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 3 Jul 2019 03:38:48 -0700 Subject: [PATCH] lockmanager: tweak FSLockManager permission handling in doSingleLock() Change-Id: Ia0070cc727ca622e127456ddb0e39d007e19f169 --- includes/libs/lockmanager/FSLockManager.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/libs/lockmanager/FSLockManager.php b/includes/libs/lockmanager/FSLockManager.php index 019029c480..c00b041b33 100644 --- a/includes/libs/lockmanager/FSLockManager.php +++ b/includes/libs/lockmanager/FSLockManager.php @@ -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(); } -- 2.20.1