Merge "[FileBackend] Clear the stat cache in doQuickOperations() for sanity."
authorTim Starling <tstarling@wikimedia.org>
Tue, 20 Nov 2012 22:49:16 +0000 (22:49 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 20 Nov 2012 22:49:16 +0000 (22:49 +0000)
1  2 
includes/filebackend/FileBackendStore.php

@@@ -93,7 -93,6 +93,7 @@@ abstract class FileBackendStore extend
         *   - 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.
         *   - 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.
                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 );
  
                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
                return array();
        }
  
 +      /**
 +       * Strip long HTTP headers from a file operation
 +       *
 +       * @param $op array 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] );
 +                              }
 +                      }
 +              }
 +              return $op;
 +      }
 +
        /**
         * @see FileBackend::preloadCache()
         */