Index: trunk/phase3/includes/api/ApiImport.php |
— | — | @@ -65,16 +65,11 @@ |
66 | 66 | } |
67 | 67 | $source = ImportStreamSource::newFromUpload( 'xml' ); |
68 | 68 | } |
69 | | - if ( $source instanceof WikiErrorMsg ) { |
70 | | - $this->dieUsageMsg( array_merge( |
71 | | - array( $source->getMessageKey() ), |
72 | | - $source->getMessageArgs() ) ); |
73 | | - } elseif ( WikiError::isError( $source ) ) { |
74 | | - // This shouldn't happen |
75 | | - $this->dieUsageMsg( array( 'import-unknownerror', $source->getMessage() ) ); |
| 69 | + if ( !$source->isOK() ) { |
| 70 | + $this->dieUsageMsg( $source->getErrorsArray() ); |
76 | 71 | } |
77 | 72 | |
78 | | - $importer = new WikiImporter( $source ); |
| 73 | + $importer = new WikiImporter( $source->value ); |
79 | 74 | if ( isset( $params['namespace'] ) ) { |
80 | 75 | $importer->setTargetNamespace( $params['namespace'] ); |
81 | 76 | } |
Index: trunk/phase3/includes/specials/SpecialImport.php |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 : $wgRequest->getIntOrNull( 'pagelink-depth' ); |
83 | 83 | |
84 | 84 | if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'editToken' ) ) ) { |
85 | | - $source = new WikiErrorMsg( 'import-token-mismatch' ); |
| 85 | + $source = Status::newFatal( 'import-token-mismatch' ); |
86 | 86 | } elseif ( $sourceName == 'upload' ) { |
87 | 87 | $isUpload = true; |
88 | 88 | if( $wgUser->isAllowed( 'importupload' ) ) { |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | } elseif ( $sourceName == "interwiki" ) { |
94 | 94 | $this->interwiki = $wgRequest->getVal( 'interwiki' ); |
95 | 95 | if ( !in_array( $this->interwiki, $wgImportSources ) ) { |
96 | | - $source = new WikiErrorMsg( "import-invalid-interwiki" ); |
| 96 | + $source = Status::newFatal( "import-invalid-interwiki" ); |
97 | 97 | } else { |
98 | 98 | $this->history = $wgRequest->getCheck( 'interwikiHistory' ); |
99 | 99 | $this->frompage = $wgRequest->getText( "frompage" ); |
— | — | @@ -105,15 +105,15 @@ |
106 | 106 | $this->pageLinkDepth ); |
107 | 107 | } |
108 | 108 | } else { |
109 | | - $source = new WikiErrorMsg( "importunknownsource" ); |
| 109 | + $source = Status::newFatal( "importunknownsource" ); |
110 | 110 | } |
111 | 111 | |
112 | | - if( WikiError::isError( $source ) ) { |
113 | | - $wgOut->wrapWikiMsg( "<p class=\"error\">\n$1\n</p>", array( 'importfailed', $source->getMessage() ) ); |
| 112 | + if( !$source->isGood() ) { |
| 113 | + $wgOut->wrapWikiMsg( "<p class=\"error\">\n$1\n</p>", array( 'importfailed', $source->getWikiText() ) ); |
114 | 114 | } else { |
115 | 115 | $wgOut->addWikiMsg( "importstart" ); |
116 | 116 | |
117 | | - $importer = new WikiImporter( $source ); |
| 117 | + $importer = new WikiImporter( $source->value ); |
118 | 118 | if( !is_null( $this->namespace ) ) { |
119 | 119 | $importer->setTargetNamespace( $this->namespace ); |
120 | 120 | } |
Index: trunk/phase3/includes/Import.php |
— | — | @@ -414,27 +414,27 @@ |
415 | 415 | static function newFromFile( $filename ) { |
416 | 416 | $file = @fopen( $filename, 'rt' ); |
417 | 417 | if( !$file ) { |
418 | | - return new WikiErrorMsg( "importcantopen" ); |
| 418 | + return Status::newFatal( "importcantopen" ); |
419 | 419 | } |
420 | | - return new ImportStreamSource( $file ); |
| 420 | + return Status::newGood( new ImportStreamSource( $file ) ); |
421 | 421 | } |
422 | 422 | |
423 | 423 | static function newFromUpload( $fieldname = "xmlimport" ) { |
424 | 424 | $upload =& $_FILES[$fieldname]; |
425 | 425 | |
426 | 426 | if( !isset( $upload ) || !$upload['name'] ) { |
427 | | - return new WikiErrorMsg( 'importnofile' ); |
| 427 | + return Status::newFatal( 'importnofile' ); |
428 | 428 | } |
429 | 429 | if( !empty( $upload['error'] ) ) { |
430 | 430 | switch($upload['error']){ |
431 | 431 | case 1: # The uploaded file exceeds the upload_max_filesize directive in php.ini. |
432 | | - return new WikiErrorMsg( 'importuploaderrorsize' ); |
| 432 | + return Status::newFatal( 'importuploaderrorsize' ); |
433 | 433 | case 2: # The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form. |
434 | | - return new WikiErrorMsg( 'importuploaderrorsize' ); |
| 434 | + return Status::newFatal( 'importuploaderrorsize' ); |
435 | 435 | case 3: # The uploaded file was only partially uploaded |
436 | | - return new WikiErrorMsg( 'importuploaderrorpartial' ); |
| 436 | + return Status::newFatal( 'importuploaderrorpartial' ); |
437 | 437 | case 6: #Missing a temporary folder. |
438 | | - return new WikiErrorMsg( 'importuploaderrortemp' ); |
| 438 | + return Status::newFatal( 'importuploaderrortemp' ); |
439 | 439 | # case else: # Currently impossible |
440 | 440 | } |
441 | 441 | |
— | — | @@ -443,7 +443,7 @@ |
444 | 444 | if( is_uploaded_file( $fname ) ) { |
445 | 445 | return ImportStreamSource::newFromFile( $fname ); |
446 | 446 | } else { |
447 | | - return new WikiErrorMsg( 'importnofile' ); |
| 447 | + return Status::newFatal( 'importnofile' ); |
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
— | — | @@ -459,19 +459,19 @@ |
460 | 460 | fwrite( $file, $data ); |
461 | 461 | fflush( $file ); |
462 | 462 | fseek( $file, 0 ); |
463 | | - return new ImportStreamSource( $file ); |
| 463 | + return Status::newGood( new ImportStreamSource( $file ) ); |
464 | 464 | } else { |
465 | | - return new WikiErrorMsg( 'importcantopen' ); |
| 465 | + return Status::newFatal( 'importcantopen' ); |
466 | 466 | } |
467 | 467 | } |
468 | 468 | |
469 | 469 | public static function newFromInterwiki( $interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0 ) { |
470 | 470 | if( $page == '' ) { |
471 | | - return new WikiErrorMsg( 'import-noarticle' ); |
| 471 | + return Status::newFatal( 'import-noarticle' ); |
472 | 472 | } |
473 | 473 | $link = Title::newFromText( "$interwiki:Special:Export/$page" ); |
474 | 474 | if( is_null( $link ) || $link->getInterwiki() == '' ) { |
475 | | - return new WikiErrorMsg( 'importbadinterwiki' ); |
| 475 | + return Status::newFatal( 'importbadinterwiki' ); |
476 | 476 | } else { |
477 | 477 | $params = array(); |
478 | 478 | if ( $history ) $params['history'] = 1; |