X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiImport.php;h=b46f0b1e5105d46cc2833336c2b7f5bfc0e430f7;hb=53ecf20db8bfc2109553e80bf932dac7321d63ec;hp=3f48f38a0ef18312d01d6c881d7338f8b05e4e99;hpb=9aba586d3b758719d9aa08b236a9de93956b6a96;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiImport.php b/includes/api/ApiImport.php index 3f48f38a0e..b46f0b1e51 100644 --- a/includes/api/ApiImport.php +++ b/includes/api/ApiImport.php @@ -64,6 +64,14 @@ class ApiImport extends ApiBase { $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'] ); @@ -79,11 +87,14 @@ class ApiImport extends ApiBase { $params['interwikisource'], $params['summary'] ); + if ( $params['tags'] ) { + $reporter->setChangeTags( $params['tags'] ); + } try { $importer->doImport(); } catch ( Exception $e ) { - $this->dieWithError( [ 'apierror-import-unknownerror', wfEscapeWikiText( $e->getMessage() ) ] ); + $this->dieWithException( $e, [ 'wrap' => 'apierror-import-unknownerror' ] ); } $resultData = $reporter->getData(); @@ -140,6 +151,10 @@ class ApiImport extends ApiBase { ApiBase::PARAM_TYPE => 'namespace' ], 'rootpage' => null, + 'tags' => [ + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ], ]; } @@ -156,7 +171,7 @@ class ApiImport extends ApiBase { } public function getHelpUrls() { - return 'https://www.mediawiki.org/wiki/API:Import'; + return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Import'; } }