Index: trunk/extensions/WikiSync/WikiSyncClient.php |
— | — | @@ -565,29 +565,19 @@ |
566 | 566 | return $json_result->getResult( 'no_import_rights' ); |
567 | 567 | } |
568 | 568 | $source = ImportStreamSource::newFromFile( $fname ); |
569 | | - if ( $source instanceof WikiErrorMsg || |
570 | | - WikiError::isError( $source ) ) { |
| 569 | + if ( !$source->isOK() ) { |
571 | 570 | @unlink( $fname ); |
572 | | - return $json_result->getResult( 'import', $source->getMessage() ); |
| 571 | + return $json_result->getResult( 'import', $source->getWikiText() ); |
573 | 572 | } |
574 | | - $importer = new WikiImporter( $source ); |
| 573 | + $importer = new WikiImporter( $source->value ); |
575 | 574 | $reporter = new WikiSyncImportReporter( $importer, true, '', wfMsg( 'wikisync_log_imported_by' ) ); |
576 | | - $result = $importer->doImport(); |
577 | | - @fclose( $source->mHandle ); |
578 | | - @unlink( $fname ); |
579 | | - if ( $result instanceof WikiXmlError ) { |
580 | | - $r = |
581 | | - array( |
582 | | - 'line' => $result->mLine, |
583 | | - 'column' => $result->mColumn, |
584 | | - 'context' => $result->mByte . $result->mContext, |
585 | | - 'xmlerror' => xml_error_string( $result->mXmlError ) |
586 | | - ); |
587 | | - $json_result->append( $r ); |
588 | | - return $json_result->getResult( 'import', $result->getMessage() ); |
589 | | - } elseif ( WikiError::isError( $result ) ) { |
590 | | - return $json_result->getResult( 'import', $source->getMessage() ); |
| 575 | + try { |
| 576 | + $importer->doImport(); |
| 577 | + } catch ( MWException $e ) { |
| 578 | + return $json_result->getResult( 'import', $e->getMessage() ); |
591 | 579 | } |
| 580 | + @fclose( $source->value->mHandle ); |
| 581 | + @unlink( $fname ); |
592 | 582 | $resultData = $reporter->getData(); |
593 | 583 | $json_result->setStatus( '1' ); // API success |
594 | 584 | return $json_result->getResult(); |
Index: trunk/extensions/DataTransfer/specials/DT_ImportCSV.php |
— | — | @@ -73,12 +73,12 @@ |
74 | 74 | if ( $wgRequest->getCheck( 'import_file' ) ) { |
75 | 75 | $text = "<p>" . wfMsg( 'dt_import_importing' ) . "</p>\n"; |
76 | 76 | $source = ImportStreamSource::newFromUpload( "csv_file" ); |
77 | | - if ( $source instanceof WikiErrorMsg ) { |
78 | | - $text .= $source->getMessage(); |
| 77 | + if ( !$source->isOK() ) { |
| 78 | + $text .= $wgOut->parse( $source->getWikiText() ); |
79 | 79 | } else { |
80 | 80 | $encoding = $wgRequest->getVal( 'encoding' ); |
81 | 81 | $pages = array(); |
82 | | - $error_msg = self::getCSVData( $source->mHandle, $encoding, $pages ); |
| 82 | + $error_msg = self::getCSVData( $source->value->mHandle, $encoding, $pages ); |
83 | 83 | if ( ! is_null( $error_msg ) ) { |
84 | 84 | $text .= $error_msg; |
85 | 85 | } else { |