From: Aaron Schulz Date: Tue, 6 Oct 2015 21:43:12 +0000 (-0700) Subject: Fix duplicate automatic file backend bug X-Git-Tag: 1.31.0-rc.0~9522^2 X-Git-Url: http://git.cyclocoop.org/data/Fool?a=commitdiff_plain;h=28194278eab509ccb55fa5af5dd67c3344ea771c;p=lhc%2Fweb%2Fwiklou.git Fix duplicate automatic file backend bug Follow-up 8a3816529a Bug: T114810 Change-Id: I2706c90077627b3df35fe530e0a919cfd0a75d78 --- diff --git a/includes/filebackend/FileBackendGroup.php b/includes/filebackend/FileBackendGroup.php index 59b2fd60c0..b6ddbad256 100644 --- a/includes/filebackend/FileBackendGroup.php +++ b/includes/filebackend/FileBackendGroup.php @@ -63,6 +63,9 @@ class FileBackendGroup { protected function initFromGlobals() { global $wgLocalFileRepo, $wgForeignFileRepos, $wgFileBackends; + // Register explicitly defined backends + $this->register( $wgFileBackends, wfConfiguredReadOnlyReason() ); + $autoBackends = array(); // Automatically create b/c backends for file repos... $repos = array_merge( $wgForeignFileRepos, array( $wgLocalFileRepo ) ); @@ -102,25 +105,18 @@ class FileBackendGroup { ); } - $backends = array_merge( $autoBackends, $wgFileBackends ); - - // Apply $wgReadOnly to all backends if not already read-only - foreach ( $backends as &$backend ) { - $backend['readOnly'] = !empty( $backend['readOnly'] ) - ? $backend['readOnly'] - : wfConfiguredReadOnlyReason(); - } - - $this->register( $backends ); + // Register implicitly defined backends + $this->register( $autoBackends, wfConfiguredReadOnlyReason() ); } /** * Register an array of file backend configurations * * @param array $configs + * @param string|null $readOnlyReason * @throws FileBackendException */ - protected function register( array $configs ) { + protected function register( array $configs, $readOnlyReason = null ) { foreach ( $configs as $config ) { if ( !isset( $config['name'] ) ) { throw new FileBackendException( "Cannot register a backend with no name." ); @@ -133,6 +129,10 @@ class FileBackendGroup { } $class = $config['class']; + $config['readOnly'] = !empty( $config['readOnly'] ) + ? $config['readOnly'] + : $readOnlyReason; + unset( $config['class'] ); // backend won't need this $this->backends[$name] = array( 'class' => $class,