Merge "[FileBackend] Made it easy to use registed file backend config in multi-write...
authorTim Starling <tstarling@wikimedia.org>
Thu, 17 May 2012 07:08:51 +0000 (07:08 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 17 May 2012 07:08:51 +0000 (07:08 +0000)
1  2 
includes/filerepo/backend/FileBackendMultiWrite.php

@@@ -57,6 -57,9 +57,9 @@@ class FileBackendMultiWrite extends Fil
         *                     FileBackendStore class, but with these additional settings:
         *                         'class'         : The name of the backend class
         *                         'isMultiMaster' : This must be set for one backend.
+        *                         'template:      : If given a backend name, this will use
+        *                                           the config of that backend as a template.
+        *                                           Values specified here take precedence.
         *     'syncChecks'  : Integer bitfield of internal backend sync checks to perform.
         *                     Possible bits include self::CHECK_SIZE and self::CHECK_TIME.
         *                     The checks are done before allowing any file operations.
                // Construct backends here rather than via registration
                // to keep these backends hidden from outside the proxy.
                foreach ( $config['backends'] as $index => $config ) {
+                       if ( isset( $config['template'] ) ) {
+                               // Config is just a modified version of a registered backend's.
+                               // This should only be used when that config is used only be this backend.
+                               $config = $config + FileBackendGroup::singleton()->config( $config['template'] );
+                       }
                        $name = $config['name'];
                        if ( isset( $namesUsed[$name] ) ) { // don't break FileOp predicates
                                throw new MWException( "Two or more backends defined with the name $name." );
                }
  
                // Actually attempt the operation batch...
 -              $subStatus = FileOp::attemptBatch( $performOps, $opts, $this->fileJournal );
 +              $subStatus = FileOpBatch::attempt( $performOps, $opts, $this->fileJournal );
  
                $success = array();
                $failCount = 0;