Merge "filebackend: cleaned up the FileBackend constructor"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 10 Dec 2013 22:09:21 +0000 (22:09 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 10 Dec 2013 22:09:21 +0000 (22:09 +0000)
1  2 
includes/filebackend/FileBackend.php
includes/filebackend/FileBackendGroup.php
includes/filebackend/FileBackendMultiWrite.php
tests/phpunit/includes/media/SVGTest.php

@@@ -131,18 -108,23 +131,23 @@@ abstract class FileBackend 
        public function __construct( array $config ) {
                $this->name = $config['name'];
                if ( !preg_match( '!^[a-zA-Z0-9-_]{1,255}$!', $this->name ) ) {
 -                      throw new MWException( "Backend name `{$this->name}` is invalid." );
 +                      throw new FileBackendException( "Backend name `{$this->name}` is invalid." );
                }
-               $this->wikiId = isset( $config['wikiId'] )
-                       ? $config['wikiId']
-                       : wfWikiID(); // e.g. "my_wiki-en_"
-               $this->lockManager = ( $config['lockManager'] instanceof LockManager )
+               if ( !isset( $config['wikiId'] ) ) {
+                       $config['wikiId'] = wfWikiID();
+                       wfDeprecated( __METHOD__ . ' called without "wikiID".', '1.23' );
+               }
+               if ( isset( $config['lockManager'] ) && !is_object( $config['lockManager'] ) ) {
+                       $config['lockManager'] =
+                               LockManagerGroup::singleton( $config['wikiId'] )->get( $config['lockManager'] );
+                       wfDeprecated( __METHOD__ . ' called with non-object "lockManager".', '1.23' );
+               }
+               $this->wikiId = $config['wikiId']; // e.g. "my_wiki-en_"
+               $this->lockManager = isset( $config['lockManager'] )
                        ? $config['lockManager']
-                       : LockManagerGroup::singleton( $this->wikiId )->get( $config['lockManager'] );
+                       : new NullLockManager( array() );
                $this->fileJournal = isset( $config['fileJournal'] )
-                       ? ( ( $config['fileJournal'] instanceof FileJournal )
-                               ? $config['fileJournal']
-                               : FileJournal::factory( $config['fileJournal'], $this->name ) )
+                       ? $config['fileJournal']
                        : FileJournal::factory( array( 'class' => 'NullFileJournal' ), $this->name );
                $this->readOnly = isset( $config['readOnly'] )
                        ? (string)$config['readOnly']
@@@ -125,11 -125,11 +125,11 @@@ class FileBackendMultiWrite extends Fil
                        // Alter certain sub-backend settings for sanity
                        unset( $config['readOnly'] ); // use proxy backend setting
                        unset( $config['fileJournal'] ); // use proxy backend journal
+                       unset( $config['lockManager'] ); // lock under proxy backend
                        $config['wikiId'] = $this->wikiId; // use the proxy backend wiki ID
-                       $config['lockManager'] = 'nullLockManager'; // lock under proxy backend
                        if ( !empty( $config['isMultiMaster'] ) ) {
                                if ( $this->masterIndex >= 0 ) {
 -                                      throw new MWException( 'More than one master backend defined.' );
 +                                      throw new FileBackendError( 'More than one master backend defined.' );
                                }
                                $this->masterIndex = $index; // this is the "master"
                                $config['fileJournal'] = $this->fileJournal; // log under proxy backend