$isUpload = false;
if ( isset( $params['interwikisource'] ) ) {
if ( !$user->isAllowed( 'import' ) ) {
- $this->dieUsageMsg( 'cantimport' );
+ $this->dieWithError( 'apierror-cantimport' );
}
if ( !isset( $params['interwikipage'] ) ) {
- $this->dieUsageMsg( [ 'missingparam', 'interwikipage' ] );
+ $this->dieWithError( [ 'apierror-missingparam', 'interwikipage' ] );
}
$source = ImportStreamSource::newFromInterwiki(
$params['interwikisource'],
} else {
$isUpload = true;
if ( !$user->isAllowed( 'importupload' ) ) {
- $this->dieUsageMsg( 'cantimport-upload' );
+ $this->dieWithError( 'apierror-cantimport-upload' );
}
$source = ImportStreamSource::newFromUpload( 'xml' );
}
$this->dieStatus( $source );
}
+ // Check if user can add the log entry tags which were requested
+ if ( $params['tags'] ) {
+ $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
+ if ( !$ableToTag->isOK() ) {
+ $this->dieStatus( $ableToTag );
+ }
+ }
+
$importer = new WikiImporter( $source->value, $this->getConfig() );
if ( isset( $params['namespace'] ) ) {
$importer->setTargetNamespace( $params['namespace'] );
$params['interwikisource'],
$params['summary']
);
+ if ( $params['tags'] ) {
+ $reporter->setChangeTags( $params['tags'] );
+ }
try {
$importer->doImport();
} catch ( Exception $e ) {
- $this->dieUsageMsg( [ 'import-unknownerror', $e->getMessage() ] );
+ $this->dieWithException( $e, [ 'wrap' => 'apierror-import-unknownerror' ] );
}
$resultData = $reporter->getData();
ApiBase::PARAM_TYPE => 'namespace'
],
'rootpage' => null,
+ 'tags' => [
+ ApiBase::PARAM_TYPE => 'tags',
+ ApiBase::PARAM_ISMULTI => true,
+ ],
];
}
}
public function getHelpUrls() {
- return 'https://www.mediawiki.org/wiki/API:Import';
+ return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Import';
}
}