Fixed broken quickDescribe() method
[lhc/web/wiklou.git] / includes / filebackend / FileBackendMultiWrite.php
index f090e24..97584a7 100644 (file)
@@ -136,26 +136,15 @@ class FileBackendMultiWrite extends FileBackend {
                }
        }
 
-       /**
-        * @see FileBackend::doOperationsInternal()
-        * @return Status
-        */
        final protected function doOperationsInternal( array $ops, array $opts ) {
                $status = Status::newGood();
 
                $mbe = $this->backends[$this->masterIndex]; // convenience
 
-               // Get the paths to lock from the master backend
-               $realOps = $this->substOpBatchPaths( $ops, $mbe );
-               $paths = $mbe->getPathsToLockForOpsInternal( $mbe->getOperationsInternal( $realOps ) );
-               // Get the paths under the proxy backend's name
-               $paths['sh'] = $this->unsubstPaths( $paths['sh'] );
-               $paths['ex'] = $this->unsubstPaths( $paths['ex'] );
                // Try to lock those files for the scope of this function...
                if ( empty( $opts['nonLocking'] ) ) {
                        // Try to lock those files for the scope of this function...
-                       $scopeLockS = $this->getScopedFileLocks( $paths['sh'], LockManager::LOCK_UW, $status );
-                       $scopeLockE = $this->getScopedFileLocks( $paths['ex'], LockManager::LOCK_EX, $status );
+                       $scopeLock = $this->getScopedLocksForOps( $ops, $status );
                        if ( !$status->isOK() ) {
                                return $status; // abort
                        }
@@ -182,6 +171,7 @@ class FileBackendMultiWrite extends FileBackend {
                        }
                }
                // Actually attempt the operation batch on the master backend...
+               $realOps = $this->substOpBatchPaths( $ops, $mbe );
                $masterStatus = $mbe->doOperations( $realOps, $opts );
                $status->merge( $masterStatus );
                // Propagate the operations to the clone backends if there were no unexpected errors
@@ -445,10 +435,6 @@ class FileBackendMultiWrite extends FileBackend {
                );
        }
 
-       /**
-        * @see FileBackend::doQuickOperationsInternal()
-        * @return Status
-        */
        protected function doQuickOperationsInternal( array $ops ) {
                $status = Status::newGood();
                // Do the operations on the master backend; setting Status fields...
@@ -482,10 +468,6 @@ class FileBackendMultiWrite extends FileBackend {
                return !in_array( $shortCont, $this->noPushDirConts );
        }
 
-       /**
-        * @see FileBackend::doPrepare()
-        * @return Status
-        */
        protected function doPrepare( array $params ) {
                $status = Status::newGood();
                $replicate = $this->replicateContainerDirChanges( $params['dir'] );
@@ -498,11 +480,6 @@ class FileBackendMultiWrite extends FileBackend {
                return $status;
        }
 
-       /**
-        * @see FileBackend::doSecure()
-        * @param array $params
-        * @return Status
-        */
        protected function doSecure( array $params ) {
                $status = Status::newGood();
                $replicate = $this->replicateContainerDirChanges( $params['dir'] );
@@ -515,11 +492,6 @@ class FileBackendMultiWrite extends FileBackend {
                return $status;
        }
 
-       /**
-        * @see FileBackend::doPublish()
-        * @param array $params
-        * @return Status
-        */
        protected function doPublish( array $params ) {
                $status = Status::newGood();
                $replicate = $this->replicateContainerDirChanges( $params['dir'] );
@@ -532,11 +504,6 @@ class FileBackendMultiWrite extends FileBackend {
                return $status;
        }
 
-       /**
-        * @see FileBackend::doClean()
-        * @param array $params
-        * @return Status
-        */
        protected function doClean( array $params ) {
                $status = Status::newGood();
                $replicate = $this->replicateContainerDirChanges( $params['dir'] );
@@ -549,62 +516,32 @@ class FileBackendMultiWrite extends FileBackend {
                return $status;
        }
 
-       /**
-        * @see FileBackend::concatenate()
-        * @param array $params
-        * @return Status
-        */
        public function concatenate( array $params ) {
                // We are writing to an FS file, so we don't need to do this per-backend
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->concatenate( $realParams );
        }
 
-       /**
-        * @see FileBackend::fileExists()
-        * @param array $params
-        * @return bool|null
-        */
        public function fileExists( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->fileExists( $realParams );
        }
 
-       /**
-        * @see FileBackend::getFileTimestamp()
-        * @param array $params
-        * @return bool|string
-        */
        public function getFileTimestamp( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->getFileTimestamp( $realParams );
        }
 
-       /**
-        * @see FileBackend::getFileSize()
-        * @param array $params
-        * @return bool|int
-        */
        public function getFileSize( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->getFileSize( $realParams );
        }
 
-       /**
-        * @see FileBackend::getFileStat()
-        * @param array $params
-        * @return Array|bool|null
-        */
        public function getFileStat( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->getFileStat( $realParams );
        }
 
-       /**
-        * @see FileBackend::getFileContentsMulti()
-        * @param array $params
-        * @return bool|string
-        */
        public function getFileContentsMulti( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                $contentsM = $this->backends[$this->masterIndex]->getFileContentsMulti( $realParams );
@@ -616,41 +553,21 @@ class FileBackendMultiWrite extends FileBackend {
                return $contents;
        }
 
-       /**
-        * @see FileBackend::getFileSha1Base36()
-        * @param array $params
-        * @return bool|string
-        */
        public function getFileSha1Base36( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->getFileSha1Base36( $realParams );
        }
 
-       /**
-        * @see FileBackend::getFileProps()
-        * @param array $params
-        * @return Array
-        */
        public function getFileProps( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->getFileProps( $realParams );
        }
 
-       /**
-        * @see FileBackend::streamFile()
-        * @param array $params
-        * @return \Status
-        */
        public function streamFile( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->streamFile( $realParams );
        }
 
-       /**
-        * @see FileBackend::getLocalReferenceMulti()
-        * @param array $params
-        * @return FSFile|null
-        */
        public function getLocalReferenceMulti( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                $fsFilesM = $this->backends[$this->masterIndex]->getLocalReferenceMulti( $realParams );
@@ -662,11 +579,6 @@ class FileBackendMultiWrite extends FileBackend {
                return $fsFiles;
        }
 
-       /**
-        * @see FileBackend::getLocalCopyMulti()
-        * @param array $params
-        * @return null|TempFSFile
-        */
        public function getLocalCopyMulti( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                $tempFilesM = $this->backends[$this->masterIndex]->getLocalCopyMulti( $realParams );
@@ -678,48 +590,26 @@ class FileBackendMultiWrite extends FileBackend {
                return $tempFiles;
        }
 
-       /**
-        * @see FileBackend::getFileHttpUrl()
-        * @return string|null
-        */
        public function getFileHttpUrl( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->getFileHttpUrl( $realParams );
        }
 
-       /**
-        * @see FileBackend::directoryExists()
-        * @param array $params
-        * @return bool|null
-        */
        public function directoryExists( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->directoryExists( $realParams );
        }
 
-       /**
-        * @see FileBackend::getSubdirectoryList()
-        * @param array $params
-        * @return Array|null|Traversable
-        */
        public function getDirectoryList( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->getDirectoryList( $realParams );
        }
 
-       /**
-        * @see FileBackend::getFileList()
-        * @param array $params
-        * @return Array|null|\Traversable
-        */
        public function getFileList( array $params ) {
                $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
                return $this->backends[$this->masterIndex]->getFileList( $realParams );
        }
 
-       /**
-        * @see FileBackend::clearCache()
-        */
        public function clearCache( array $paths = null ) {
                foreach ( $this->backends as $backend ) {
                        $realPaths = is_array( $paths ) ? $this->substPaths( $paths, $backend ) : null;
@@ -727,19 +617,17 @@ class FileBackendMultiWrite extends FileBackend {
                }
        }
 
-       /**
-        * @see FileBackend::getScopedLocksForOps()
-        */
        public function getScopedLocksForOps( array $ops, Status $status ) {
-               $fileOps = $this->backends[$this->masterIndex]->getOperationsInternal( $ops );
+               $realOps = $this->substOpBatchPaths( $ops, $this->backends[$this->masterIndex] );
+               $fileOps = $this->backends[$this->masterIndex]->getOperationsInternal( $realOps );
                // Get the paths to lock from the master backend
                $paths = $this->backends[$this->masterIndex]->getPathsToLockForOpsInternal( $fileOps );
                // Get the paths under the proxy backend's name
-               $paths['sh'] = $this->unsubstPaths( $paths['sh'] );
-               $paths['ex'] = $this->unsubstPaths( $paths['ex'] );
-               return array(
-                       $this->getScopedFileLocks( $paths['sh'], LockManager::LOCK_UW, $status ),
-                       $this->getScopedFileLocks( $paths['ex'], LockManager::LOCK_EX, $status )
+               $pbPaths = array(
+                       LockManager::LOCK_UW => $this->unsubstPaths( $paths[LockManager::LOCK_UW] ),
+                       LockManager::LOCK_EX => $this->unsubstPaths( $paths[LockManager::LOCK_EX] )
                );
+               // Actually acquire the locks
+               return array( $this->getScopedFileLocks( $pbPaths, 'mixed', $status ) );
        }
 }