From: jenkins-bot Date: Tue, 10 Dec 2013 22:09:21 +0000 (+0000) Subject: Merge "filebackend: cleaned up the FileBackend constructor" X-Git-Tag: 1.31.0-rc.0~17683 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=76dc1986514cc2da47a0d3872bac8cdcb4ef80e5;p=lhc%2Fweb%2Fwiklou.git Merge "filebackend: cleaned up the FileBackend constructor" --- 76dc1986514cc2da47a0d3872bac8cdcb4ef80e5 diff --cc includes/filebackend/FileBackend.php index 0e9a41df41,6e3028887b..bb21f1b5e4 --- a/includes/filebackend/FileBackend.php +++ b/includes/filebackend/FileBackend.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'] diff --cc includes/filebackend/FileBackendMultiWrite.php index 612b19b188,cb7a58e79e..1c9832de74 --- a/includes/filebackend/FileBackendMultiWrite.php +++ b/includes/filebackend/FileBackendMultiWrite.php @@@ -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