r77801 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77800‎ | r77801 | r77802 >
Date:14:31, 5 December 2010
Author:ialex
Status:deferred
Tags:
Comment:
Follow-up r77800: fix extensions using static methods from ImportSourceStream to take the object from the correct place
Modified paths:
  • /trunk/extensions/DataTransfer/specials/DT_ImportCSV.php (modified) (history)
  • /trunk/extensions/WikiSync/WikiSyncClient.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiSync/WikiSyncClient.php
@@ -565,29 +565,19 @@
566566 return $json_result->getResult( 'no_import_rights' );
567567 }
568568 $source = ImportStreamSource::newFromFile( $fname );
569 - if ( $source instanceof WikiErrorMsg ||
570 - WikiError::isError( $source ) ) {
 569+ if ( !$source->isOK() ) {
571570 @unlink( $fname );
572 - return $json_result->getResult( 'import', $source->getMessage() );
 571+ return $json_result->getResult( 'import', $source->getWikiText() );
573572 }
574 - $importer = new WikiImporter( $source );
 573+ $importer = new WikiImporter( $source->value );
575574 $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() );
591579 }
 580+ @fclose( $source->value->mHandle );
 581+ @unlink( $fname );
592582 $resultData = $reporter->getData();
593583 $json_result->setStatus( '1' ); // API success
594584 return $json_result->getResult();
Index: trunk/extensions/DataTransfer/specials/DT_ImportCSV.php
@@ -73,12 +73,12 @@
7474 if ( $wgRequest->getCheck( 'import_file' ) ) {
7575 $text = "<p>" . wfMsg( 'dt_import_importing' ) . "</p>\n";
7676 $source = ImportStreamSource::newFromUpload( "csv_file" );
77 - if ( $source instanceof WikiErrorMsg ) {
78 - $text .= $source->getMessage();
 77+ if ( !$source->isOK() ) {
 78+ $text .= $wgOut->parse( $source->getWikiText() );
7979 } else {
8080 $encoding = $wgRequest->getVal( 'encoding' );
8181 $pages = array();
82 - $error_msg = self::getCSVData( $source->mHandle, $encoding, $pages );
 82+ $error_msg = self::getCSVData( $source->value->mHandle, $encoding, $pages );
8383 if ( ! is_null( $error_msg ) ) {
8484 $text .= $error_msg;
8585 } else {

Follow-up revisions

RevisionCommit summaryAuthorDate
r78399Re-added compatibility for MW 1.16 and earlier, removed by ialex in r77801yaron20:58, 14 December 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r77800Converted ImportStreamSource functions to return a Status object rather than ...ialex14:22, 5 December 2010

Status & tagging log