r77569 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77568‎ | r77569 | r77570 >
Date:09:51, 2 December 2010
Author:ialex
Status:ok
Tags:
Comment:
* Convert ImportReporter::close() to use Status objects instead of int-or-WikiError
* WikiImporter::doImport() no longer returns a WikiError object but throws a MWException
Modified paths:
  • /trunk/phase3/includes/specials/SpecialImport.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialImport.php
@@ -118,17 +118,22 @@
119119 $importer->setTargetNamespace( $this->namespace );
120120 }
121121 $reporter = new ImportReporter( $importer, $isUpload, $this->interwiki , $this->logcomment);
 122+ $exception = false;
122123
123124 $reporter->open();
124 - $result = $importer->doImport();
125 - $resultCount = $reporter->close();
 125+ try {
 126+ $importer->doImport();
 127+ } catch ( MWException $e ) {
 128+ $exception = $e;
 129+ }
 130+ $result = $reporter->close();
126131
127 - if( WikiError::isError( $result ) ) {
 132+ if ( $exception ) {
128133 # No source or XML parse error
129 - $wgOut->wrapWikiMsg( "<p class=\"error\">\n$1\n</p>", array( 'importfailed', $result->getMessage() ) );
130 - } elseif( WikiError::isError( $resultCount ) ) {
 134+ $wgOut->wrapWikiMsg( "<p class=\"error\">\n$1\n</p>", array( 'importfailed', $exception->getMessage() ) );
 135+ } elseif( !$result->isGood() ) {
131136 # Zero revisions
132 - $wgOut->wrapWikiMsg( "<p class=\"error\">\n$1\n</p>", array( 'importfailed', $resultCount->getMessage() ) );
 137+ $wgOut->wrapWikiMsg( "<p class=\"error\">\n$1\n</p>", array( 'importfailed', $result->getWikiText() ) );
133138 } else {
134139 # Success!
135140 $wgOut->addWikiMsg( 'importsuccess' );
@@ -369,10 +374,10 @@
370375 $wgOut->addHTML( Xml::tags( 'li', null, $msg ) );
371376 } elseif( $this->mPageCount == 0 && $this->mLogItemCount == 0 ) {
372377 $wgOut->addHTML( "</ul>\n" );
373 - return new WikiErrorMsg( "importnopages" );
 378+ return Status::newFatal( 'importnopages' );
374379 }
375380 $wgOut->addHTML( "</ul>\n" );
376381
377 - return $this->mPageCount;
 382+ return Status::newGood( $this->mPageCount );
378383 }
379384 }

Status & tagging log