- if($source instanceof WikiErrorMsg)
- $this->dieUsageMsg(array_merge(
- array($source->getMessageKey()),
- $source->getMessageArgs()));
- else if(WikiError::isError($source))
- // This shouldn't happen
- $this->dieUsageMsg(array('import-unknownerror', $source->getMessage()));
-
- $importer = new WikiImporter($source);
- if(isset($params['namespace']))
- $importer->setTargetNamespace($params['namespace']);
- $reporter = new ApiImportReporter($importer, $isUpload,
- $params['interwikisource'],
- $params['summary']);
-
- $result = $importer->doImport();
- if($result instanceof WikiXmlError)
- $this->dieUsageMsg(array('import-xml-error',
- $result->mLine,
- $result->mColumn,
- $result->mByte . $result->mContext,
- xml_error_string($result->mXmlError)));
- else if(WikiError::isError($result))
- // This shouldn't happen
- $this->dieUsageMsg(array('import-unknownerror', $result->getMessage()));
+
+ $importer = new WikiImporter( $source->value );
+ if ( isset( $params['namespace'] ) ) {
+ $importer->setTargetNamespace( $params['namespace'] );
+ }
+ $reporter = new ApiImportReporter(
+ $importer,
+ $isUpload,
+ $params['interwikisource'],
+ $params['summary']
+ );
+
+ try {
+ $importer->doImport();
+ } catch ( MWException $e ) {
+ $this->dieUsageMsg( array( 'import-unknownerror', $e->getMessage() ) );
+ }
+