From: Alexandre Emsenhuber Date: Thu, 2 Dec 2010 09:51:00 +0000 (+0000) Subject: * Convert ImportReporter::close() to use Status objects instead of int-or-WikiError X-Git-Tag: 1.31.0-rc.0~33645 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=838923670e876a37314bcf520b54dcead0ae54ab;p=lhc%2Fweb%2Fwiklou.git * Convert ImportReporter::close() to use Status objects instead of int-or-WikiError * WikiImporter::doImport() no longer returns a WikiError object but throws a MWException --- diff --git a/includes/specials/SpecialImport.php b/includes/specials/SpecialImport.php index ae00e3f48c..4f28744676 100644 --- a/includes/specials/SpecialImport.php +++ b/includes/specials/SpecialImport.php @@ -118,17 +118,22 @@ class SpecialImport extends SpecialPage { $importer->setTargetNamespace( $this->namespace ); } $reporter = new ImportReporter( $importer, $isUpload, $this->interwiki , $this->logcomment); + $exception = false; $reporter->open(); - $result = $importer->doImport(); - $resultCount = $reporter->close(); + try { + $importer->doImport(); + } catch ( MWException $e ) { + $exception = $e; + } + $result = $reporter->close(); - if( WikiError::isError( $result ) ) { + if ( $exception ) { # No source or XML parse error - $wgOut->wrapWikiMsg( "

\n$1\n

", array( 'importfailed', $result->getMessage() ) ); - } elseif( WikiError::isError( $resultCount ) ) { + $wgOut->wrapWikiMsg( "

\n$1\n

", array( 'importfailed', $exception->getMessage() ) ); + } elseif( !$result->isGood() ) { # Zero revisions - $wgOut->wrapWikiMsg( "

\n$1\n

", array( 'importfailed', $resultCount->getMessage() ) ); + $wgOut->wrapWikiMsg( "

\n$1\n

", array( 'importfailed', $result->getWikiText() ) ); } else { # Success! $wgOut->addWikiMsg( 'importsuccess' ); @@ -369,10 +374,10 @@ class ImportReporter { $wgOut->addHTML( Xml::tags( 'li', null, $msg ) ); } elseif( $this->mPageCount == 0 && $this->mLogItemCount == 0 ) { $wgOut->addHTML( "\n" ); - return new WikiErrorMsg( "importnopages" ); + return Status::newFatal( 'importnopages' ); } $wgOut->addHTML( "\n" ); - return $this->mPageCount; + return Status::newGood( $this->mPageCount ); } }