Merge "Parse duplicate-defaultsort error message"
[lhc/web/wiklou.git] / includes / filebackend / FileBackendStore.php
index e20c6fc..e976a7a 100644 (file)
@@ -55,7 +55,7 @@ abstract class FileBackendStore extends FileBackend {
        /**
         * @see FileBackend::__construct()
         *
-        * @param $config Array
+        * @param array $config
         */
        public function __construct( array $config ) {
                parent::__construct( $config );
@@ -81,7 +81,7 @@ abstract class FileBackendStore extends FileBackend {
         * written under it, and that any file already there is writable.
         * Backends using key/value stores should check if the container exists.
         *
-        * @param $storagePath string
+        * @param string $storagePath
         * @return bool
         */
        abstract public function isPathUsableInternal( $storagePath );
@@ -105,8 +105,7 @@ abstract class FileBackendStore extends FileBackend {
         * @return Status
         */
        final public function createInternal( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                if ( strlen( $params['content'] ) > $this->maxFileSizeInternal() ) {
                        $status = Status::newFatal( 'backend-fail-maxsize',
                                $params['dst'], $this->maxFileSizeInternal() );
@@ -117,8 +116,6 @@ abstract class FileBackendStore extends FileBackend {
                                $this->deleteFileCache( $params['dst'] ); // persistent cache
                        }
                }
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -147,8 +144,7 @@ abstract class FileBackendStore extends FileBackend {
         * @return Status
         */
        final public function storeInternal( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                if ( filesize( $params['src'] ) > $this->maxFileSizeInternal() ) {
                        $status = Status::newFatal( 'backend-fail-maxsize',
                                $params['dst'], $this->maxFileSizeInternal() );
@@ -159,8 +155,6 @@ abstract class FileBackendStore extends FileBackend {
                                $this->deleteFileCache( $params['dst'] ); // persistent cache
                        }
                }
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -190,15 +184,12 @@ abstract class FileBackendStore extends FileBackend {
         * @return Status
         */
        final public function copyInternal( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $status = $this->doCopyInternal( $params );
                $this->clearCache( array( $params['dst'] ) );
                if ( !isset( $params['dstExists'] ) || $params['dstExists'] ) {
                        $this->deleteFileCache( $params['dst'] ); // persistent cache
                }
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -223,13 +214,10 @@ abstract class FileBackendStore extends FileBackend {
         * @return Status
         */
        final public function deleteInternal( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $status = $this->doDeleteInternal( $params );
                $this->clearCache( array( $params['src'] ) );
                $this->deleteFileCache( $params['src'] ); // persistent cache
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -259,16 +247,13 @@ abstract class FileBackendStore extends FileBackend {
         * @return Status
         */
        final public function moveInternal( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $status = $this->doMoveInternal( $params );
                $this->clearCache( array( $params['src'], $params['dst'] ) );
                $this->deleteFileCache( $params['src'] ); // persistent cache
                if ( !isset( $params['dstExists'] ) || $params['dstExists'] ) {
                        $this->deleteFileCache( $params['dst'] ); // persistent cache
                }
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -305,8 +290,7 @@ abstract class FileBackendStore extends FileBackend {
         * @return Status
         */
        final public function describeInternal( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                if ( count( $params['headers'] ) ) {
                        $status = $this->doDescribeInternal( $params );
                        $this->clearCache( array( $params['src'] ) );
@@ -314,8 +298,6 @@ abstract class FileBackendStore extends FileBackend {
                } else {
                        $status = Status::newGood(); // nothing to do
                }
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -338,13 +320,8 @@ abstract class FileBackendStore extends FileBackend {
                return Status::newGood();
        }
 
-       /**
-        * @see FileBackend::concatenate()
-        * @return Status
-        */
        final public function concatenate( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $status = Status::newGood();
 
                // Try to lock the source files for the scope of this function
@@ -360,8 +337,6 @@ abstract class FileBackendStore extends FileBackend {
                        }
                }
 
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -431,20 +406,13 @@ abstract class FileBackendStore extends FileBackend {
                return $status;
        }
 
-       /**
-        * @see FileBackend::doPrepare()
-        * @return Status
-        */
        final protected function doPrepare( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
-
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $status = Status::newGood();
+
                list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
                if ( $dir === null ) {
                        $status->fatal( 'backend-fail-invalidpath', $params['dir'] );
-                       wfProfileOut( __METHOD__ . '-' . $this->name );
-                       wfProfileOut( __METHOD__ );
                        return $status; // invalid storage path
                }
 
@@ -458,8 +426,6 @@ abstract class FileBackendStore extends FileBackend {
                        }
                }
 
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -471,20 +437,13 @@ abstract class FileBackendStore extends FileBackend {
                return Status::newGood();
        }
 
-       /**
-        * @see FileBackend::doSecure()
-        * @return Status
-        */
        final protected function doSecure( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $status = Status::newGood();
 
                list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
                if ( $dir === null ) {
                        $status->fatal( 'backend-fail-invalidpath', $params['dir'] );
-                       wfProfileOut( __METHOD__ . '-' . $this->name );
-                       wfProfileOut( __METHOD__ );
                        return $status; // invalid storage path
                }
 
@@ -498,8 +457,6 @@ abstract class FileBackendStore extends FileBackend {
                        }
                }
 
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -511,20 +468,13 @@ abstract class FileBackendStore extends FileBackend {
                return Status::newGood();
        }
 
-       /**
-        * @see FileBackend::doPublish()
-        * @return Status
-        */
        final protected function doPublish( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $status = Status::newGood();
 
                list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
                if ( $dir === null ) {
                        $status->fatal( 'backend-fail-invalidpath', $params['dir'] );
-                       wfProfileOut( __METHOD__ . '-' . $this->name );
-                       wfProfileOut( __METHOD__ );
                        return $status; // invalid storage path
                }
 
@@ -538,8 +488,6 @@ abstract class FileBackendStore extends FileBackend {
                        }
                }
 
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -551,13 +499,8 @@ abstract class FileBackendStore extends FileBackend {
                return Status::newGood();
        }
 
-       /**
-        * @see FileBackend::doClean()
-        * @return Status
-        */
        final protected function doClean( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $status = Status::newGood();
 
                // Recursive: first delete all empty subdirs recursively
@@ -575,8 +518,6 @@ abstract class FileBackendStore extends FileBackend {
                list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
                if ( $dir === null ) {
                        $status->fatal( 'backend-fail-invalidpath', $params['dir'] );
-                       wfProfileOut( __METHOD__ . '-' . $this->name );
-                       wfProfileOut( __METHOD__ );
                        return $status; // invalid storage path
                }
 
@@ -584,8 +525,6 @@ abstract class FileBackendStore extends FileBackend {
                $filesLockEx = array( $params['dir'] );
                $scopedLockE = $this->getScopedFileLocks( $filesLockEx, LockManager::LOCK_EX, $status );
                if ( !$status->isOK() ) {
-                       wfProfileOut( __METHOD__ . '-' . $this->name );
-                       wfProfileOut( __METHOD__ );
                        return $status; // abort
                }
 
@@ -601,8 +540,6 @@ abstract class FileBackendStore extends FileBackend {
                        }
                }
 
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -614,56 +551,30 @@ abstract class FileBackendStore extends FileBackend {
                return Status::newGood();
        }
 
-       /**
-        * @see FileBackend::fileExists()
-        * @return bool|null
-        */
        final public function fileExists( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $stat = $this->getFileStat( $params );
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return ( $stat === null ) ? null : (bool)$stat; // null => failure
        }
 
-       /**
-        * @see FileBackend::getFileTimestamp()
-        * @return bool
-        */
        final public function getFileTimestamp( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $stat = $this->getFileStat( $params );
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $stat ? $stat['mtime'] : false;
        }
 
-       /**
-        * @see FileBackend::getFileSize()
-        * @return bool
-        */
        final public function getFileSize( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $stat = $this->getFileStat( $params );
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $stat ? $stat['size'] : false;
        }
 
-       /**
-        * @see FileBackend::getFileStat()
-        * @return bool
-        */
        final public function getFileStat( array $params ) {
                $path = self::normalizeStoragePath( $params['src'] );
                if ( $path === null ) {
                        return false; // invalid storage path
                }
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $latest = !empty( $params['latest'] ); // use latest data?
                if ( !$this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) {
                        $this->primeFileCache( array( $path ) ); // check persistent cache
@@ -674,14 +585,10 @@ abstract class FileBackendStore extends FileBackend {
                        // value was in fact fetched with the latest available data.
                        if ( is_array( $stat ) ) {
                                if ( !$latest || $stat['latest'] ) {
-                                       wfProfileOut( __METHOD__ . '-' . $this->name );
-                                       wfProfileOut( __METHOD__ );
                                        return $stat;
                                }
                        } elseif ( in_array( $stat, array( 'NOT_EXIST', 'NOT_EXIST_LATEST' ) ) ) {
                                if ( !$latest || $stat === 'NOT_EXIST_LATEST' ) {
-                                       wfProfileOut( __METHOD__ . '-' . $this->name );
-                                       wfProfileOut( __METHOD__ );
                                        return false;
                                }
                        }
@@ -707,8 +614,6 @@ abstract class FileBackendStore extends FileBackend {
                } else { // an error occurred
                        wfDebug( __METHOD__ . ": Could not stat file $path.\n" );
                }
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $stat;
        }
 
@@ -717,19 +622,12 @@ abstract class FileBackendStore extends FileBackend {
         */
        abstract protected function doGetFileStat( array $params );
 
-       /**
-        * @see FileBackend::getFileContentsMulti()
-        * @return Array
-        */
        public function getFileContentsMulti( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
 
                $params = $this->setConcurrencyFlags( $params );
                $contents = $this->doGetFileContentsMulti( $params );
 
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $contents;
        }
 
@@ -747,25 +645,18 @@ abstract class FileBackendStore extends FileBackend {
                return $contents;
        }
 
-       /**
-        * @see FileBackend::getFileSha1Base36()
-        * @return bool|string
-        */
        final public function getFileSha1Base36( array $params ) {
                $path = self::normalizeStoragePath( $params['src'] );
                if ( $path === null ) {
                        return false; // invalid storage path
                }
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $latest = !empty( $params['latest'] ); // use latest data?
                if ( $this->cheapCache->has( $path, 'sha1', self::CACHE_TTL ) ) {
                        $stat = $this->cheapCache->get( $path, 'sha1' );
                        // If we want the latest data, check that this cached
                        // value was in fact fetched with the latest available data.
                        if ( !$latest || $stat['latest'] ) {
-                               wfProfileOut( __METHOD__ . '-' . $this->name );
-                               wfProfileOut( __METHOD__ );
                                return $stat['hash'];
                        }
                }
@@ -775,8 +666,6 @@ abstract class FileBackendStore extends FileBackend {
                wfProfileOut( __METHOD__ . '-miss-' . $this->name );
                wfProfileOut( __METHOD__ . '-miss' );
                $this->cheapCache->set( $path, 'sha1', array( 'hash' => $hash, 'latest' => $latest ) );
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $hash;
        }
 
@@ -793,27 +682,15 @@ abstract class FileBackendStore extends FileBackend {
                }
        }
 
-       /**
-        * @see FileBackend::getFileProps()
-        * @return Array
-        */
        final public function getFileProps( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $fsFile = $this->getLocalReference( $params );
                $props = $fsFile ? $fsFile->getProps() : FSFile::placeholderProps();
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $props;
        }
 
-       /**
-        * @see FileBackend::getLocalReferenceMulti()
-        * @return Array
-        */
        final public function getLocalReferenceMulti( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
 
                $params = $this->setConcurrencyFlags( $params );
 
@@ -843,8 +720,6 @@ abstract class FileBackendStore extends FileBackend {
                        }
                }
 
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $fsFiles;
        }
 
@@ -856,19 +731,12 @@ abstract class FileBackendStore extends FileBackend {
                return $this->doGetLocalCopyMulti( $params );
        }
 
-       /**
-        * @see FileBackend::getLocalCopyMulti()
-        * @return Array
-        */
        final public function getLocalCopyMulti( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
 
                $params = $this->setConcurrencyFlags( $params );
                $tmpFiles = $this->doGetLocalCopyMulti( $params );
 
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $tmpFiles;
        }
 
@@ -886,13 +754,8 @@ abstract class FileBackendStore extends FileBackend {
                return null; // not supported
        }
 
-       /**
-        * @see FileBackend::streamFile()
-        * @return Status
-        */
        final public function streamFile( array $params ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $status = Status::newGood();
 
                $info = $this->getFileStat( $params );
@@ -923,8 +786,6 @@ abstract class FileBackendStore extends FileBackend {
                        $status->fatal( 'backend-fail-stream', $params['src'] );
                }
 
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -945,10 +806,6 @@ abstract class FileBackendStore extends FileBackend {
                return $status;
        }
 
-       /**
-        * @see FileBackend::directoryExists()
-        * @return bool|null
-        */
        final public function directoryExists( array $params ) {
                list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
                if ( $dir === null ) {
@@ -983,10 +840,6 @@ abstract class FileBackendStore extends FileBackend {
         */
        abstract protected function doDirectoryExists( $container, $dir, array $params );
 
-       /**
-        * @see FileBackend::getDirectoryList()
-        * @return Traversable|Array|null Returns null on failure
-        */
        final public function getDirectoryList( array $params ) {
                list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
                if ( $dir === null ) { // invalid storage path
@@ -1016,10 +869,6 @@ abstract class FileBackendStore extends FileBackend {
         */
        abstract public function getDirectoryListInternal( $container, $dir, array $params );
 
-       /**
-        * @see FileBackend::getFileList()
-        * @return Traversable|Array|null Returns null on failure
-        */
        final public function getFileList( array $params ) {
                list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
                if ( $dir === null ) { // invalid storage path
@@ -1113,10 +962,6 @@ abstract class FileBackendStore extends FileBackend {
                return $paths;
        }
 
-       /**
-        * @see FileBackend::getScopedLocksForOps()
-        * @return Array
-        */
        public function getScopedLocksForOps( array $ops, Status $status ) {
                $paths = $this->getPathsToLockForOpsInternal( $this->getOperationsInternal( $ops ) );
                return array(
@@ -1125,13 +970,8 @@ abstract class FileBackendStore extends FileBackend {
                );
        }
 
-       /**
-        * @see FileBackend::doOperationsInternal()
-        * @return Status
-        */
        final protected function doOperationsInternal( array $ops, array $opts ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $status = Status::newGood();
 
                // Fix up custom header name/value pairs...
@@ -1148,8 +988,6 @@ abstract class FileBackendStore extends FileBackend {
                        $scopeLockS = $this->getScopedFileLocks( $paths['sh'], LockManager::LOCK_UW, $status );
                        $scopeLockE = $this->getScopedFileLocks( $paths['ex'], LockManager::LOCK_EX, $status );
                        if ( !$status->isOK() ) {
-                               wfProfileOut( __METHOD__ . '-' . $this->name );
-                               wfProfileOut( __METHOD__ );
                                return $status; // abort
                        }
                }
@@ -1171,19 +1009,11 @@ abstract class FileBackendStore extends FileBackend {
                $status->merge( $subStatus );
                $status->success = $subStatus->success; // not done in merge()
 
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
-       /**
-        * @see FileBackend::doQuickOperationsInternal()
-        * @return Status
-        * @throws MWException
-        */
        final protected function doQuickOperationsInternal( array $ops ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                $status = Status::newGood();
 
                // Fix up custom header name/value pairs...
@@ -1193,7 +1023,7 @@ abstract class FileBackendStore extends FileBackend {
                $this->clearCache();
 
                $supportedOps = array( 'create', 'store', 'copy', 'move', 'delete', 'null' );
-               $async = ( $this->parallelize === 'implicit' );
+               $async = ( $this->parallelize === 'implicit' && count( $ops ) > 1 );
                $maxConcurrency = $this->concurrency; // throttle
 
                $statuses = array(); // array of (index => Status)
@@ -1202,8 +1032,6 @@ abstract class FileBackendStore extends FileBackend {
                // Perform the sync-only ops and build up op handles for the async ops...
                foreach ( $ops as $index => $params ) {
                        if ( !in_array( $params['op'], $supportedOps ) ) {
-                               wfProfileOut( __METHOD__ . '-' . $this->name );
-                               wfProfileOut( __METHOD__ );
                                throw new MWException( "Operation '{$params['op']}' is not supported." );
                        }
                        $method = $params['op'] . 'Internal'; // e.g. "storeInternal"
@@ -1237,8 +1065,6 @@ abstract class FileBackendStore extends FileBackend {
                        }
                }
 
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -1252,16 +1078,11 @@ abstract class FileBackendStore extends FileBackend {
         * @throws MWException
         */
        final public function executeOpHandlesInternal( array $fileOpHandles ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
                foreach ( $fileOpHandles as $fileOpHandle ) {
                        if ( !( $fileOpHandle instanceof FileBackendStoreOpHandle ) ) {
-                               wfProfileOut( __METHOD__ . '-' . $this->name );
-                               wfProfileOut( __METHOD__ );
                                throw new MWException( "Given a non-FileBackendStoreOpHandle object." );
                        } elseif ( $fileOpHandle->backend->getName() !== $this->getName() ) {
-                               wfProfileOut( __METHOD__ . '-' . $this->name );
-                               wfProfileOut( __METHOD__ );
                                throw new MWException( "Given a FileBackendStoreOpHandle for the wrong backend." );
                        }
                }
@@ -1269,8 +1090,6 @@ abstract class FileBackendStore extends FileBackend {
                foreach ( $fileOpHandles as $fileOpHandle ) {
                        $fileOpHandle->closeResources();
                }
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
                return $res;
        }
 
@@ -1312,9 +1131,6 @@ abstract class FileBackendStore extends FileBackend {
                return $op;
        }
 
-       /**
-        * @see FileBackend::preloadCache()
-        */
        final public function preloadCache( array $paths ) {
                $fullConts = array(); // full container names
                foreach ( $paths as $path ) {
@@ -1326,9 +1142,6 @@ abstract class FileBackendStore extends FileBackend {
                $this->primeFileCache( $paths );
        }
 
-       /**
-        * @see FileBackend::clearCache()
-        */
        final public function clearCache( array $paths = null ) {
                if ( is_array( $paths ) ) {
                        $paths = array_map( 'FileBackend::normalizeStoragePath', $paths );
@@ -1369,7 +1182,7 @@ abstract class FileBackendStore extends FileBackend {
         * Check if a container name is valid.
         * This checks for for length and illegal characters.
         *
-        * @param $container string
+        * @param string $container
         * @return bool
         */
        final protected static function isValidContainerName( $container ) {
@@ -1391,7 +1204,7 @@ abstract class FileBackendStore extends FileBackend {
         * this means that the path can only refer to a directory and can only
         * be scanned by looking in all the container shards.
         *
-        * @param $storagePath string
+        * @param string $storagePath
         * @return Array (container, path, container suffix) or (null, null, null) if invalid
         */
        final protected function resolveStoragePath( $storagePath ) {
@@ -1431,7 +1244,7 @@ abstract class FileBackendStore extends FileBackend {
         *
         * @see FileBackendStore::resolveStoragePath()
         *
-        * @param $storagePath string
+        * @param string $storagePath
         * @return Array (container, path) or (null, null) if invalid
         */
        final protected function resolveStoragePathReal( $storagePath ) {
@@ -1496,7 +1309,7 @@ abstract class FileBackendStore extends FileBackend {
         * If greater than 0, then all file storage paths within
         * the container are required to be hashed accordingly.
         *
-        * @param $container string
+        * @param string $container
         * @return Array (integer levels, integer base, repeat flag) or (0, 0, false)
         */
        final protected function getContainerHashLevels( $container ) {
@@ -1516,7 +1329,7 @@ abstract class FileBackendStore extends FileBackend {
        /**
         * Get a list of full container shard suffixes for a container
         *
-        * @param $container string
+        * @param string $container
         * @return Array
         */
        final protected function getContainerSuffixes( $container ) {
@@ -1534,7 +1347,7 @@ abstract class FileBackendStore extends FileBackend {
        /**
         * Get the full container name, including the wiki ID prefix
         *
-        * @param $container string
+        * @param string $container
         * @return string
         */
        final protected function fullContainerName( $container ) {
@@ -1550,7 +1363,7 @@ abstract class FileBackendStore extends FileBackend {
         * This is intended for internal use, such as encoding illegal chars.
         * Subclasses can override this to be more restrictive.
         *
-        * @param $container string
+        * @param string $container
         * @return string|null
         */
        protected function resolveContainerName( $container ) {
@@ -1610,12 +1423,11 @@ abstract class FileBackendStore extends FileBackend {
         * used in a list of container names, storage paths, or FileOp objects.
         * This loads the persistent cache values into the process cache.
         *
-        * @param $items Array
+        * @param Array $items
         * @return void
         */
        final protected function primeContainerCache( array $items ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
 
                $paths = array(); // list of storage paths
                $contNames = array(); // (cache key => resolved container name)
@@ -1647,9 +1459,6 @@ abstract class FileBackendStore extends FileBackend {
 
                // Populate the container process cache for the backend...
                $this->doPrimeContainerCache( array_filter( $contInfo, 'is_array' ) );
-
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -1719,8 +1528,7 @@ abstract class FileBackendStore extends FileBackend {
         * @return void
         */
        final protected function primeFileCache( array $items ) {
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
 
                $paths = array(); // list of storage paths
                $pathNames = array(); // (cache key => storage path)
@@ -1754,9 +1562,6 @@ abstract class FileBackendStore extends FileBackend {
                                }
                        }
                }
-
-               wfProfileOut( __METHOD__ . '-' . $this->name );
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -1827,7 +1632,7 @@ abstract class FileBackendStoreShardListIterator extends FilterIterator {
        protected $multiShardPaths = array(); // (rel path => 1)
 
        /**
-        * @param $backend FileBackendStore
+        * @param FileBackendStore $backend
         * @param string $container Full storage container name
         * @param string $dir Storage directory relative to container
         * @param array $suffixes List of container shard suffixes