Index: trunk/phase3/includes/specials/SpecialImport.php |
— | — | @@ -118,17 +118,22 @@ |
119 | 119 | $importer->setTargetNamespace( $this->namespace ); |
120 | 120 | } |
121 | 121 | $reporter = new ImportReporter( $importer, $isUpload, $this->interwiki , $this->logcomment); |
| 122 | + $exception = false; |
122 | 123 | |
123 | 124 | $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(); |
126 | 131 | |
127 | | - if( WikiError::isError( $result ) ) { |
| 132 | + if ( $exception ) { |
128 | 133 | # 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() ) { |
131 | 136 | # 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() ) ); |
133 | 138 | } else { |
134 | 139 | # Success! |
135 | 140 | $wgOut->addWikiMsg( 'importsuccess' ); |
— | — | @@ -369,10 +374,10 @@ |
370 | 375 | $wgOut->addHTML( Xml::tags( 'li', null, $msg ) ); |
371 | 376 | } elseif( $this->mPageCount == 0 && $this->mLogItemCount == 0 ) { |
372 | 377 | $wgOut->addHTML( "</ul>\n" ); |
373 | | - return new WikiErrorMsg( "importnopages" ); |
| 378 | + return Status::newFatal( 'importnopages' ); |
374 | 379 | } |
375 | 380 | $wgOut->addHTML( "</ul>\n" ); |
376 | 381 | |
377 | | - return $this->mPageCount; |
| 382 | + return Status::newGood( $this->mPageCount ); |
378 | 383 | } |
379 | 384 | } |