Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/312464

Change subject: Move FileBackendMultiWrite to /libs
......................................................................

Move FileBackendMultiWrite to /libs

Change-Id: I8079693a62db390028cd9f72b2bd7a81ae1164c3
---
M autoload.php
M includes/DefaultSettings.php
M includes/filebackend/FileBackendGroup.php
R includes/libs/filebackend/FileBackendMultiWrite.php
4 files changed, 15 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/64/312464/1

diff --git a/autoload.php b/autoload.php
index a352884..292f12e 100644
--- a/autoload.php
+++ b/autoload.php
@@ -458,7 +458,7 @@
        'FileBackendDBRepoWrapper' => __DIR__ . 
'/includes/filerepo/FileBackendDBRepoWrapper.php',
        'FileBackendError' => __DIR__ . 
'/includes/libs/filebackend/FileBackendError.php',
        'FileBackendGroup' => __DIR__ . 
'/includes/filebackend/FileBackendGroup.php',
-       'FileBackendMultiWrite' => __DIR__ . 
'/includes/filebackend/FileBackendMultiWrite.php',
+       'FileBackendMultiWrite' => __DIR__ . 
'/includes/libs/filebackend/FileBackendMultiWrite.php',
        'FileBackendStore' => __DIR__ . 
'/includes/filebackend/FileBackendStore.php',
        'FileBackendStoreOpHandle' => __DIR__ . 
'/includes/filebackend/FileBackendStore.php',
        'FileBackendStoreShardDirIterator' => __DIR__ . 
'/includes/filebackend/FileBackendStore.php',
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index aa54629..1cb2f7d 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -616,6 +616,11 @@
  * Additional parameters are specific to the file backend class used.
  * These settings should be global to all wikis when possible.
  *
+ * FileBackendMultiWrite::__construct() is augmented with a 'template' option 
that
+ * can be used in any of the values of the 'backends' array. Its value is the 
name of
+ * another backend in $wgFileBackends. When set, it pre-fills the array with 
all of the
+ * configuration of the named backend. Explicitly set values in the array take 
precedence.
+ *
  * There are two particularly important aspects about each backend:
  *   - a) Whether it is fully qualified or wiki-relative.
  *        By default, the paths of files are relative to the current wiki,
diff --git a/includes/filebackend/FileBackendGroup.php 
b/includes/filebackend/FileBackendGroup.php
index d0a99d4..2099e6f 100644
--- a/includes/filebackend/FileBackendGroup.php
+++ b/includes/filebackend/FileBackendGroup.php
@@ -169,6 +169,15 @@
                        $config['mimeCallback'] = [ $this, 'guessMimeInternal' 
];
                        $config['statusWrapper'] = [ 'Status', 'wrap' ];
                        $config['tmpDirectory'] = wfTempDir();
+                       if ( $class === 'FileBackendMultiWrite' ) {
+                               foreach ( $config['backends'] as $index => 
$beConfig ) {
+                                       if ( isset( $beConfig['template'] ) ) {
+                                               // Config is just a modified 
version of a registered backend's.
+                                               // This should only be used 
when that config is used only by this backend.
+                                               $config['backends'][$index] += 
$this->config( $beConfig['template'] );
+                                       }
+                               }
+                       }
 
                        $this->backends[$name]['instance'] = new $class( 
$config );
                }
diff --git a/includes/filebackend/FileBackendMultiWrite.php 
b/includes/libs/filebackend/FileBackendMultiWrite.php
similarity index 97%
rename from includes/filebackend/FileBackendMultiWrite.php
rename to includes/libs/filebackend/FileBackendMultiWrite.php
index 52b84d4..3234b72 100644
--- a/includes/filebackend/FileBackendMultiWrite.php
+++ b/includes/libs/filebackend/FileBackendMultiWrite.php
@@ -74,9 +74,6 @@
         *                        - class         : The name of the backend 
class
         *                        - isMultiMaster : This must be set for one 
backend.
         *                        - readAffinity  : Use this for reads without 
'latest' set.
-        *                        - 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 the 
FileBackendMultiWrite::CHECK_* constants.
         *                      There are constants for SIZE, TIME, and SHA1.
@@ -107,11 +104,6 @@
                // to keep these backends hidden from outside the proxy.
                $namesUsed = [];
                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 by this backend.
-                               $config = $config + 
FileBackendGroup::singleton()->config( $config['template'] );
-                       }
                        $name = $config['name'];
                        if ( isset( $namesUsed[$name] ) ) { // don't break 
FileOp predicates
                                throw new LogicException( "Two or more backends 
defined with the name $name." );

-- 
To view, visit https://gerrit.wikimedia.org/r/312464
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8079693a62db390028cd9f72b2bd7a81ae1164c3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to