Merge "Adding output parameter to PageHistoryBeforeList hook"
[lhc/web/wiklou.git] / includes / filebackend / FileBackendStore.php
index 0f435a3..3f1d185 100644 (file)
@@ -57,8 +57,8 @@ abstract class FileBackendStore extends FileBackend {
         */
        public function __construct( array $config ) {
                parent::__construct( $config );
-               $this->memCache       = new EmptyBagOStuff(); // disabled by default
-               $this->cheapCache     = new ProcessCacheLRU( 300 );
+               $this->memCache = new EmptyBagOStuff(); // disabled by default
+               $this->cheapCache = new ProcessCacheLRU( 300 );
                $this->expensiveCache = new ProcessCacheLRU( 5 );
        }
 
@@ -90,14 +90,17 @@ abstract class FileBackendStore extends FileBackend {
         * Do not call this function from places outside FileBackend and FileOp.
         *
         * $params include:
-        *   - content       : the raw file contents
-        *   - dst           : destination storage path
-        *   - disposition   : Content-Disposition header value for the destination
-        *   - async         : Status will be returned immediately if supported.
-        *                     If the status is OK, then its value field will be
-        *                     set to a FileBackendStoreOpHandle object.
+        *   - content     : the raw file contents
+        *   - dst         : destination storage path
+        *   - disposition : Content-Disposition header value for the destination
+        *   - headers     : HTTP header name/value map
+        *   - async       : Status will be returned immediately if supported.
+        *                   If the status is OK, then its value field will be
+        *                   set to a FileBackendStoreOpHandle object.
+        *   - dstExists   : Whether a file exists at the destination (optimization).
+        *                   Callers can use "false" if no existing file is being changed.
         *
-        * @param $params Array
+        * @param array $params
         * @return Status
         */
        final public function createInternal( array $params ) {
@@ -109,7 +112,9 @@ abstract class FileBackendStore extends FileBackend {
                } else {
                        $status = $this->doCreateInternal( $params );
                        $this->clearCache( array( $params['dst'] ) );
-                       $this->deleteFileCache( $params['dst'] ); // persistent cache
+                       if ( !isset( $params['dstExists'] ) || $params['dstExists'] ) {
+                               $this->deleteFileCache( $params['dst'] ); // persistent cache
+                       }
                }
                wfProfileOut( __METHOD__ . '-' . $this->name );
                wfProfileOut( __METHOD__ );
@@ -118,6 +123,7 @@ abstract class FileBackendStore extends FileBackend {
 
        /**
         * @see FileBackendStore::createInternal()
+        * @return Status
         */
        abstract protected function doCreateInternal( array $params );
 
@@ -127,14 +133,17 @@ abstract class FileBackendStore extends FileBackend {
         * Do not call this function from places outside FileBackend and FileOp.
         *
         * $params include:
-        *   - src           : source path on disk
-        *   - dst           : destination storage path
-        *   - disposition   : Content-Disposition header value for the destination
-        *   - async         : Status will be returned immediately if supported.
-        *                     If the status is OK, then its value field will be
-        *                     set to a FileBackendStoreOpHandle object.
+        *   - src         : source path on disk
+        *   - dst         : destination storage path
+        *   - disposition : Content-Disposition header value for the destination
+        *   - headers     : HTTP header name/value map
+        *   - async       : Status will be returned immediately if supported.
+        *                   If the status is OK, then its value field will be
+        *                   set to a FileBackendStoreOpHandle object.
+        *   - dstExists   : Whether a file exists at the destination (optimization).
+        *                   Callers can use "false" if no existing file is being changed.
         *
-        * @param $params Array
+        * @param array $params
         * @return Status
         */
        final public function storeInternal( array $params ) {
@@ -146,7 +155,9 @@ abstract class FileBackendStore extends FileBackend {
                } else {
                        $status = $this->doStoreInternal( $params );
                        $this->clearCache( array( $params['dst'] ) );
-                       $this->deleteFileCache( $params['dst'] ); // persistent cache
+                       if ( !isset( $params['dstExists'] ) || $params['dstExists'] ) {
+                               $this->deleteFileCache( $params['dst'] ); // persistent cache
+                       }
                }
                wfProfileOut( __METHOD__ . '-' . $this->name );
                wfProfileOut( __METHOD__ );
@@ -155,6 +166,7 @@ abstract class FileBackendStore extends FileBackend {
 
        /**
         * @see FileBackendStore::storeInternal()
+        * @return Status
         */
        abstract protected function doStoreInternal( array $params );
 
@@ -171,8 +183,10 @@ abstract class FileBackendStore extends FileBackend {
         *   - async               : Status will be returned immediately if supported.
         *                           If the status is OK, then its value field will be
         *                           set to a FileBackendStoreOpHandle object.
+        *   - dstExists           : Whether a file exists at the destination (optimization).
+        *                           Callers can use "false" if no existing file is being changed.
         *
-        * @param $params Array
+        * @param array $params
         * @return Status
         */
        final public function copyInternal( array $params ) {
@@ -180,7 +194,9 @@ abstract class FileBackendStore extends FileBackend {
                wfProfileIn( __METHOD__ . '-' . $this->name );
                $status = $this->doCopyInternal( $params );
                $this->clearCache( array( $params['dst'] ) );
-               $this->deleteFileCache( $params['dst'] ); // persistent cache
+               if ( !isset( $params['dstExists'] ) || $params['dstExists'] ) {
+                       $this->deleteFileCache( $params['dst'] ); // persistent cache
+               }
                wfProfileOut( __METHOD__ . '-' . $this->name );
                wfProfileOut( __METHOD__ );
                return $status;
@@ -188,6 +204,7 @@ abstract class FileBackendStore extends FileBackend {
 
        /**
         * @see FileBackendStore::copyInternal()
+        * @return Status
         */
        abstract protected function doCopyInternal( array $params );
 
@@ -202,7 +219,7 @@ abstract class FileBackendStore extends FileBackend {
         *                           If the status is OK, then its value field will be
         *                           set to a FileBackendStoreOpHandle object.
         *
-        * @param $params Array
+        * @param array $params
         * @return Status
         */
        final public function deleteInternal( array $params ) {
@@ -218,6 +235,7 @@ abstract class FileBackendStore extends FileBackend {
 
        /**
         * @see FileBackendStore::deleteInternal()
+        * @return Status
         */
        abstract protected function doDeleteInternal( array $params );
 
@@ -234,8 +252,10 @@ abstract class FileBackendStore extends FileBackend {
         *   - async               : Status will be returned immediately if supported.
         *                           If the status is OK, then its value field will be
         *                           set to a FileBackendStoreOpHandle object.
+        *   - dstExists           : Whether a file exists at the destination (optimization).
+        *                           Callers can use "false" if no existing file is being changed.
         *
-        * @param $params Array
+        * @param array $params
         * @return Status
         */
        final public function moveInternal( array $params ) {
@@ -244,7 +264,9 @@ abstract class FileBackendStore extends FileBackend {
                $status = $this->doMoveInternal( $params );
                $this->clearCache( array( $params['src'], $params['dst'] ) );
                $this->deleteFileCache( $params['src'] ); // persistent cache
-               $this->deleteFileCache( $params['dst'] ); // persistent cache
+               if ( !isset( $params['dstExists'] ) || $params['dstExists'] ) {
+                       $this->deleteFileCache( $params['dst'] ); // persistent cache
+               }
                wfProfileOut( __METHOD__ . '-' . $this->name );
                wfProfileOut( __METHOD__ );
                return $status;
@@ -266,11 +288,45 @@ abstract class FileBackendStore extends FileBackend {
                return $status;
        }
 
+       /**
+        * Alter metadata for a file at the storage path.
+        * Do not call this function from places outside FileBackend and FileOp.
+        *
+        * $params include:
+        *   - src           : source storage path
+        *   - disposition   : Content-Disposition header value for the destination
+        *   - headers       : HTTP header name/value map
+        *   - async         : Status will be returned immediately if supported.
+        *                     If the status is OK, then its value field will be
+        *                     set to a FileBackendStoreOpHandle object.
+        *
+        * @param array $params
+        * @return Status
+        */
+       final public function describeInternal( array $params ) {
+               wfProfileIn( __METHOD__ );
+               wfProfileIn( __METHOD__ . '-' . $this->name );
+               $status = $this->doDescribeInternal( $params );
+               $this->clearCache( array( $params['src'] ) );
+               $this->deleteFileCache( $params['src'] ); // persistent cache
+               wfProfileOut( __METHOD__ . '-' . $this->name );
+               wfProfileOut( __METHOD__ );
+               return $status;
+       }
+
+       /**
+        * @see FileBackendStore::describeInternal()
+        * @return Status
+        */
+       protected function doDescribeInternal( array $params ) {
+               return Status::newGood();
+       }
+
        /**
         * No-op file operation that does nothing.
         * Do not call this function from places outside FileBackend and FileOp.
         *
-        * @param $params Array
+        * @param array $params
         * @return Status
         */
        final public function nullInternal( array $params ) {
@@ -391,7 +447,7 @@ abstract class FileBackendStore extends FileBackend {
                        $status->merge( $this->doPrepareInternal( $fullCont, $dir, $params ) );
                } else { // directory is on several shards
                        wfDebug( __METHOD__ . ": iterating over all container shards.\n" );
-                       list( $b, $shortCont, $r ) = self::splitStoragePath( $params['dir'] );
+                       list( , $shortCont, ) = self::splitStoragePath( $params['dir'] );
                        foreach ( $this->getContainerSuffixes( $shortCont ) as $suffix ) {
                                $status->merge( $this->doPrepareInternal( "{$fullCont}{$suffix}", $dir, $params ) );
                        }
@@ -431,7 +487,7 @@ abstract class FileBackendStore extends FileBackend {
                        $status->merge( $this->doSecureInternal( $fullCont, $dir, $params ) );
                } else { // directory is on several shards
                        wfDebug( __METHOD__ . ": iterating over all container shards.\n" );
-                       list( $b, $shortCont, $r ) = self::splitStoragePath( $params['dir'] );
+                       list( , $shortCont, ) = self::splitStoragePath( $params['dir'] );
                        foreach ( $this->getContainerSuffixes( $shortCont ) as $suffix ) {
                                $status->merge( $this->doSecureInternal( "{$fullCont}{$suffix}", $dir, $params ) );
                        }
@@ -471,7 +527,7 @@ abstract class FileBackendStore extends FileBackend {
                        $status->merge( $this->doPublishInternal( $fullCont, $dir, $params ) );
                } else { // directory is on several shards
                        wfDebug( __METHOD__ . ": iterating over all container shards.\n" );
-                       list( $b, $shortCont, $r ) = self::splitStoragePath( $params['dir'] );
+                       list( , $shortCont, ) = self::splitStoragePath( $params['dir'] );
                        foreach ( $this->getContainerSuffixes( $shortCont ) as $suffix ) {
                                $status->merge( $this->doPublishInternal( "{$fullCont}{$suffix}", $dir, $params ) );
                        }
@@ -533,7 +589,7 @@ abstract class FileBackendStore extends FileBackend {
                        $this->deleteContainerCache( $fullCont ); // purge cache
                } else { // directory is on several shards
                        wfDebug( __METHOD__ . ": iterating over all container shards.\n" );
-                       list( $b, $shortCont, $r ) = self::splitStoragePath( $params['dir'] );
+                       list( , $shortCont, ) = self::splitStoragePath( $params['dir'] );
                        foreach ( $this->getContainerSuffixes( $shortCont ) as $suffix ) {
                                $status->merge( $this->doCleanInternal( "{$fullCont}{$suffix}", $dir, $params ) );
                                $this->deleteContainerCache( "{$fullCont}{$suffix}" ); // purge cache
@@ -610,12 +666,19 @@ abstract class FileBackendStore extends FileBackend {
                if ( $this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) {
                        $stat = $this->cheapCache->get( $path, 'stat' );
                        // If we want the latest data, check that this cached
-                       // value was in fact fetched with the latest available data
-                       // (the process cache is ignored if it contains a negative).
-                       if ( !$latest || ( is_array( $stat ) && $stat['latest'] ) ) {
-                               wfProfileOut( __METHOD__ . '-' . $this->name );
-                               wfProfileOut( __METHOD__ );
-                               return $stat;
+                       // 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;
+                               }
                        }
                }
                wfProfileIn( __METHOD__ . '-miss' );
@@ -632,7 +695,7 @@ abstract class FileBackendStore extends FileBackend {
                                        array( 'hash' => $stat['sha1'], 'latest' => $latest ) );
                        }
                } elseif ( $stat === false ) { // file does not exist
-                       $this->cheapCache->set( $path, 'stat', false );
+                       $this->cheapCache->set( $path, 'stat', $latest ? 'NOT_EXIST_LATEST' : 'NOT_EXIST' );
                        wfDebug( __METHOD__ . ": File $path does not exist.\n" );
                } else { // an error occurred
                        wfDebug( __METHOD__ . ": Could not stat file $path.\n" );
@@ -704,10 +767,7 @@ abstract class FileBackendStore extends FileBackend {
                $hash = $this->doGetFileSha1Base36( $params );
                wfProfileOut( __METHOD__ . '-miss-' . $this->name );
                wfProfileOut( __METHOD__ . '-miss' );
-               if ( $hash ) { // don't cache negatives
-                       $this->cheapCache->set( $path, 'sha1',
-                               array( 'hash' => $hash, 'latest' => $latest ) );
-               }
+               $this->cheapCache->set( $path, 'sha1', array( 'hash' => $hash, 'latest' => $latest ) );
                wfProfileOut( __METHOD__ . '-' . $this->name );
                wfProfileOut( __METHOD__ );
                return $hash;
@@ -891,7 +951,7 @@ abstract class FileBackendStore extends FileBackend {
                        return $this->doDirectoryExists( $fullCont, $dir, $params );
                } else { // directory is on several shards
                        wfDebug( __METHOD__ . ": iterating over all container shards.\n" );
-                       list( $b, $shortCont, $r ) = self::splitStoragePath( $params['dir'] );
+                       list( , $shortCont, ) = self::splitStoragePath( $params['dir'] );
                        $res = false; // response
                        foreach ( $this->getContainerSuffixes( $shortCont ) as $suffix ) {
                                $exists = $this->doDirectoryExists( "{$fullCont}{$suffix}", $dir, $params );
@@ -909,9 +969,9 @@ abstract class FileBackendStore extends FileBackend {
        /**
         * @see FileBackendStore::directoryExists()
         *
-        * @param $container string Resolved container name
-        * @param $dir string Resolved path relative to container
-        * @param $params Array
+        * @param string $container Resolved container name
+        * @param string $dir Resolved path relative to container
+        * @param array $params
         * @return bool|null
         */
        abstract protected function doDirectoryExists( $container, $dir, array $params );
@@ -931,7 +991,7 @@ abstract class FileBackendStore extends FileBackend {
                } else {
                        wfDebug( __METHOD__ . ": iterating over all container shards.\n" );
                        // File listing spans multiple containers/shards
-                       list( $b, $shortCont, $r ) = self::splitStoragePath( $params['dir'] );
+                       list( , $shortCont, ) = self::splitStoragePath( $params['dir'] );
                        return new FileBackendStoreShardDirIterator( $this,
                                $fullCont, $dir, $this->getContainerSuffixes( $shortCont ), $params );
                }
@@ -942,9 +1002,9 @@ abstract class FileBackendStore extends FileBackend {
         *
         * @see FileBackendStore::getDirectoryList()
         *
-        * @param $container string Resolved container name
-        * @param $dir string Resolved path relative to container
-        * @param $params Array
+        * @param string $container Resolved container name
+        * @param string $dir Resolved path relative to container
+        * @param array $params
         * @return Traversable|Array|null Returns null on failure
         */
        abstract public function getDirectoryListInternal( $container, $dir, array $params );
@@ -964,7 +1024,7 @@ abstract class FileBackendStore extends FileBackend {
                } else {
                        wfDebug( __METHOD__ . ": iterating over all container shards.\n" );
                        // File listing spans multiple containers/shards
-                       list( $b, $shortCont, $r ) = self::splitStoragePath( $params['dir'] );
+                       list( , $shortCont, ) = self::splitStoragePath( $params['dir'] );
                        return new FileBackendStoreShardFileIterator( $this,
                                $fullCont, $dir, $this->getContainerSuffixes( $shortCont ), $params );
                }
@@ -975,9 +1035,9 @@ abstract class FileBackendStore extends FileBackend {
         *
         * @see FileBackendStore::getFileList()
         *
-        * @param $container string Resolved container name
-        * @param $dir string Resolved path relative to container
-        * @param $params Array
+        * @param string $container Resolved container name
+        * @param string $dir Resolved path relative to container
+        * @param array $params
         * @return Traversable|Array|null Returns null on failure
         */
        abstract public function getFileListInternal( $container, $dir, array $params );
@@ -989,18 +1049,19 @@ abstract class FileBackendStore extends FileBackend {
         * The result must have the same number of items as the input.
         * An exception is thrown if an unsupported operation is requested.
         *
-        * @param $ops Array Same format as doOperations()
+        * @param array $ops Same format as doOperations()
         * @return Array List of FileOp objects
         * @throws MWException
         */
        final public function getOperationsInternal( array $ops ) {
                $supportedOps = array(
-                       'store'       => 'StoreFileOp',
-                       'copy'        => 'CopyFileOp',
-                       'move'        => 'MoveFileOp',
-                       'delete'      => 'DeleteFileOp',
-                       'create'      => 'CreateFileOp',
-                       'null'        => 'NullFileOp'
+                       'store'    => 'StoreFileOp',
+                       'copy'     => 'CopyFileOp',
+                       'move'     => 'MoveFileOp',
+                       'delete'   => 'DeleteFileOp',
+                       'create'   => 'CreateFileOp',
+                       'describe' => 'DescribeFileOp',
+                       'null'     => 'NullFileOp'
                );
 
                $performOps = array(); // array of FileOp objects
@@ -1027,7 +1088,7 @@ abstract class FileBackendStore extends FileBackend {
         * each corresponding to a list of storage paths to be locked.
         * All returned paths are normalized.
         *
-        * @param $performOps Array List of FileOp objects
+        * @param array $performOps List of FileOp objects
         * @return Array ('sh' => list of paths, 'ex' => list of paths)
         */
        final public function getPathsToLockForOpsInternal( array $performOps ) {
@@ -1066,6 +1127,9 @@ abstract class FileBackendStore extends FileBackend {
                wfProfileIn( __METHOD__ . '-' . $this->name );
                $status = Status::newGood();
 
+               // Fix up custom header name/value pairs...
+               $ops = array_map( array( $this, 'stripInvalidHeadersFromOp' ), $ops );
+
                // Build up a list of FileOps...
                $performOps = $this->getOperationsInternal( $ops );
 
@@ -1115,6 +1179,12 @@ abstract class FileBackendStore extends FileBackend {
                wfProfileIn( __METHOD__ . '-' . $this->name );
                $status = Status::newGood();
 
+               // Fix up custom header name/value pairs...
+               $ops = array_map( array( $this, 'stripInvalidHeadersFromOp' ), $ops );
+
+               // Clear any file cache entries
+               $this->clearCache();
+
                $supportedOps = array( 'create', 'store', 'copy', 'move', 'delete', 'null' );
                $async = ( $this->parallelize === 'implicit' );
                $maxConcurrency = $this->concurrency; // throttle
@@ -1170,7 +1240,7 @@ abstract class FileBackendStore extends FileBackend {
         * The resulting Status object fields will correspond
         * to the order in which the handles where given.
         *
-        * @param $handles Array List of FileBackendStoreOpHandle objects
+        * @param array $handles List of FileBackendStoreOpHandle objects
         * @return Array Map of Status objects
         * @throws MWException
         */
@@ -1206,13 +1276,33 @@ abstract class FileBackendStore extends FileBackend {
                return array();
        }
 
+       /**
+        * Strip long HTTP headers from a file operation
+        *
+        * @param array $op Same format as doOperation()
+        * @return Array
+        */
+       protected function stripInvalidHeadersFromOp( array $op ) {
+               if ( isset( $op['headers'] ) ) {
+                       foreach ( $op['headers'] as $name => $value ) {
+                               if ( strlen( $name ) > 255 || strlen( $value ) > 255 ) {
+                                       trigger_error( "Header '$name: $value' is too long." );
+                                       unset( $op['headers'][$name] );
+                               } elseif ( !strlen( $value ) ) {
+                                       $op['headers'][$name] = ''; // null/false => ""
+                               }
+                       }
+               }
+               return $op;
+       }
+
        /**
         * @see FileBackend::preloadCache()
         */
        final public function preloadCache( array $paths ) {
                $fullConts = array(); // full container names
                foreach ( $paths as $path ) {
-                       list( $fullCont, $r, $s ) = $this->resolveStoragePath( $path );
+                       list( $fullCont, , ) = $this->resolveStoragePath( $path );
                        $fullConts[] = $fullCont;
                }
                // Load from the persistent file and container caches
@@ -1245,7 +1335,7 @@ abstract class FileBackendStore extends FileBackend {
         *
         * @see FileBackend::clearCache()
         *
-        * @param $paths Array Storage paths (optional)
+        * @param array $paths Storage paths (optional)
         * @return void
         */
        protected function doClearCache( array $paths = null ) {}
@@ -1334,8 +1424,8 @@ abstract class FileBackendStore extends FileBackend {
         * Get the container name shard suffix for a given path.
         * Any empty suffix means the container is not sharded.
         *
-        * @param $container string Container name
-        * @param $relPath string Storage path relative to the container
+        * @param string $container Container name
+        * @param string $relPath Storage path relative to the container
         * @return string|null Returns null if shard could not be determined
         */
        final protected function getContainerShard( $container, $relPath ) {
@@ -1371,11 +1461,11 @@ abstract class FileBackendStore extends FileBackend {
         * Container dirs like "a", where the container shards on "x/xy",
         * can reside on several shards. Such paths are tricky to handle.
         *
-        * @param $storagePath string Storage path
+        * @param string $storagePath Storage path
         * @return bool
         */
        final public function isSingleShardPathInternal( $storagePath ) {
-               list( $c, $r, $shard ) = $this->resolveStoragePath( $storagePath );
+               list( , $shard ) = $this->resolveStoragePath( $storagePath );
                return ( $shard !== null );
        }
 
@@ -1451,8 +1541,8 @@ abstract class FileBackendStore extends FileBackend {
         * getting absolute paths (e.g. FS based backends). Note that the relative path
         * may be the empty string (e.g. the path is simply to the container).
         *
-        * @param $container string Container name
-        * @param $relStoragePath string Storage path relative to the container
+        * @param string $container Container name
+        * @param string $relStoragePath Storage path relative to the container
         * @return string|null Path or null if not valid
         */
        protected function resolveContainerPath( $container, $relStoragePath ) {
@@ -1462,7 +1552,7 @@ abstract class FileBackendStore extends FileBackend {
        /**
         * Get the cache key for a container
         *
-        * @param $container string Resolved container name
+        * @param string $container Resolved container name
         * @return string
         */
        private function containerCacheKey( $container ) {
@@ -1472,7 +1562,7 @@ abstract class FileBackendStore extends FileBackend {
        /**
         * Set the cached info for a container
         *
-        * @param $container string Resolved container name
+        * @param string $container Resolved container name
         * @param $val mixed Information to cache
         */
        final protected function setContainerCache( $container, $val ) {
@@ -1483,7 +1573,7 @@ abstract class FileBackendStore extends FileBackend {
         * Delete the cached info for a container.
         * The cache key is salted for a while to prevent race conditions.
         *
-        * @param $container string Resolved container name
+        * @param string $container Resolved container name
         */
        final protected function deleteContainerCache( $container ) {
                if ( !$this->memCache->set( $this->containerCacheKey( $container ), 'PURGED', 300 ) ) {
@@ -1518,7 +1608,7 @@ abstract class FileBackendStore extends FileBackend {
                }
                // Get all the corresponding cache keys for paths...
                foreach ( $paths as $path ) {
-                       list( $fullCont, $r, $s ) = $this->resolveStoragePath( $path );
+                       list( $fullCont, , ) = $this->resolveStoragePath( $path );
                        if ( $fullCont !== null ) { // valid path for this backend
                                $contNames[$this->containerCacheKey( $fullCont )] = $fullCont;
                        }
@@ -1543,7 +1633,7 @@ abstract class FileBackendStore extends FileBackend {
         * resolved container names and their corresponding cached info.
         * Only containers that actually exist should appear in the map.
         *
-        * @param $containerInfo Array Map of resolved container names to cached info
+        * @param array $containerInfo Map of resolved container names to cached info
         * @return void
         */
        protected function doPrimeContainerCache( array $containerInfo ) {}
@@ -1551,7 +1641,7 @@ abstract class FileBackendStore extends FileBackend {
        /**
         * Get the cache key for a file path
         *
-        * @param $path string Normalized storage path
+        * @param string $path Normalized storage path
         * @return string
         */
        private function fileCacheKey( $path ) {
@@ -1563,7 +1653,7 @@ abstract class FileBackendStore extends FileBackend {
         * Negatives (404s) are not cached. By not caching negatives, we can skip cache
         * salting for the case when a file is created at a path were there was none before.
         *
-        * @param $path string Storage path
+        * @param string $path Storage path
         * @param $val mixed Information to cache
         */
        final protected function setFileCache( $path, $val ) {
@@ -1577,8 +1667,10 @@ abstract class FileBackendStore extends FileBackend {
        /**
         * Delete the cached stat info for a file path.
         * The cache key is salted for a while to prevent race conditions.
+        * Since negatives (404s) are not cached, this does not need to be called when
+        * a file is created at a path were there was none before.
         *
-        * @param $path string Storage path
+        * @param string $path Storage path
         */
        final protected function deleteFileCache( $path ) {
                $path = FileBackend::normalizeStoragePath( $path );
@@ -1595,7 +1687,7 @@ abstract class FileBackendStore extends FileBackend {
         * used in a list of storage paths or FileOp objects.
         * This loads the persistent cache values into the process cache.
         *
-        * @param $items Array List of storage paths or FileOps
+        * @param array $items List of storage paths or FileOps
         * @return void
         */
        final protected function primeFileCache( array $items ) {
@@ -1617,7 +1709,7 @@ abstract class FileBackendStore extends FileBackend {
                $paths = array_filter( $paths, 'strlen' ); // remove nulls
                // Get all the corresponding cache keys for paths...
                foreach ( $paths as $path ) {
-                       list( $cont, $rel, $s ) = $this->resolveStoragePath( $path );
+                       list( , $rel, ) = $this->resolveStoragePath( $path );
                        if ( $rel !== null ) { // valid path for this backend
                                $pathNames[$this->fileCacheKey( $path )] = $path;
                        }
@@ -1642,7 +1734,7 @@ abstract class FileBackendStore extends FileBackend {
        /**
         * Set the 'concurrency' option from a list of operation options
         *
-        * @param $opts array Map of operation options
+        * @param array $opts Map of operation options
         * @return Array
         */
        final protected function setConcurrencyFlags( array $opts ) {
@@ -1714,10 +1806,10 @@ abstract class FileBackendStoreShardListIterator implements Iterator {
 
        /**
         * @param $backend FileBackendStore
-        * @param $container string Full storage container name
-        * @param $dir string Storage directory relative to container
-        * @param $suffixes Array List of container shard suffixes
-        * @param $params Array
+        * @param string $container Full storage container name
+        * @param string $dir Storage directory relative to container
+        * @param array $suffixes List of container shard suffixes
+        * @param array $params
         */
        public function __construct(
                FileBackendStore $backend, $container, $dir, array $suffixes, array $params
@@ -1843,9 +1935,9 @@ abstract class FileBackendStoreShardListIterator implements Iterator {
        /**
         * Get the list for a given container shard
         *
-        * @param $container string Resolved container name
-        * @param $dir string Resolved path relative to container
-        * @param $params Array
+        * @param string $container Resolved container name
+        * @param string $dir Resolved path relative to container
+        * @param array $params
         * @return Traversable|Array|null
         */
        abstract protected function listFromShard( $container, $dir, array $params );