Merge "SpecialRecentChanges: Remove '@todo Uses radio buttons (HASHAR)'"
[lhc/web/wiklou.git] / includes / filebackend / FileBackend.php
index 9b4760a..4bcaa7f 100644 (file)
@@ -807,7 +807,7 @@ abstract class FileBackend {
         * @return ScopedCallback|null
         */
        final protected function getScopedPHPBehaviorForOps() {
-               if ( php_sapi_name() != 'cli' ) { // http://bugs.php.net/bug.php?id=47540
+               if ( PHP_SAPI != 'cli' ) { // http://bugs.php.net/bug.php?id=47540
                        $old = ignore_user_abort( true ); // avoid half-finished operations
                        return new ScopedCallback( function() use ( $old ) {
                                ignore_user_abort( $old );
@@ -1159,6 +1159,7 @@ abstract class FileBackend {
         * @return Status
         */
        final public function lockFiles( array $paths, $type ) {
+               $paths = array_map( 'FileBackend::normalizeStoragePath', $paths );
                return $this->lockManager->lock( $paths, $type );
        }
 
@@ -1170,6 +1171,7 @@ abstract class FileBackend {
         * @return Status
         */
        final public function unlockFiles( array $paths, $type ) {
+               $paths = array_map( 'FileBackend::normalizeStoragePath', $paths );
                return $this->lockManager->unlock( $paths, $type );
        }
 
@@ -1181,12 +1183,21 @@ abstract class FileBackend {
         * Once the return value goes out scope, the locks will be released and
         * the status updated. Unlock fatals will not change the status "OK" value.
         *
-        * @param array $paths Storage paths
-        * @param integer $type LockManager::LOCK_* constant
+        * @see ScopedLock::factory()
+        *
+        * @param array $paths List of storage paths or map of lock types to path lists
+        * @param integer|string $type LockManager::LOCK_* constant or "mixed"
         * @param Status $status Status to update on lock/unlock
         * @return ScopedLock|null Returns null on failure
         */
        final public function getScopedFileLocks( array $paths, $type, Status $status ) {
+               if ( $type === 'mixed' ) {
+                       foreach ( $paths as &$typePaths ) {
+                               $typePaths = array_map( 'FileBackend::normalizeStoragePath', $typePaths );
+                       }
+               } else {
+                       $paths = array_map( 'FileBackend::normalizeStoragePath', $paths );
+               }
                return ScopedLock::factory( $this->lockManager, $paths, $type, $status );
        }