Merge "Rename autonym for 'no' from 'norsk bokmål' to 'norsk'"
[lhc/web/wiklou.git] / includes / api / ApiImport.php
index 3f48f38..b46f0b1 100644 (file)
@@ -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';
        }
 }