Merge "Delete UIDGenerator cache files after unit tests"
[lhc/web/wiklou.git] / includes / api / ApiImport.php
index f5636bd..295f16e 100644 (file)
  */
 class ApiImport extends ApiBase {
 
-       public function __construct( $main, $action ) {
-               parent::__construct( $main, $action );
-       }
-
        public function execute() {
                $user = $this->getUser();
                $params = $this->extractRequestParams();
@@ -61,7 +57,7 @@ class ApiImport extends ApiBase {
                        $source = ImportStreamSource::newFromUpload( 'xml' );
                }
                if ( !$source->isOK() ) {
-                       $this->dieUsageMsg( $source->getErrorsArray() );
+                       $this->dieStatus( $source );
                }
 
                $importer = new WikiImporter( $source->value );
@@ -70,8 +66,8 @@ class ApiImport extends ApiBase {
                }
                if ( isset( $params['rootpage'] ) ) {
                        $statusRootPage = $importer->setTargetRootPage( $params['rootpage'] );
-                       if( !$statusRootPage->isGood() ) {
-                               $this->dieUsageMsg( $statusRootPage->getErrorsArray() );
+                       if ( !$statusRootPage->isGood() ) {
+                               $this->dieStatus( $statusRootPage );
                        }
                }
                $reporter = new ApiImportReporter(
@@ -103,13 +99,16 @@ class ApiImport extends ApiBase {
 
        public function getAllowedParams() {
                global $wgImportSources;
+
                return array(
                        'token' => array(
                                ApiBase::PARAM_TYPE => 'string',
                                ApiBase::PARAM_REQUIRED => true
                        ),
                        'summary' => null,
-                       'xml' => null,
+                       'xml' => array(
+                               ApiBase::PARAM_TYPE => 'upload',
+                       ),
                        'interwikisource' => array(
                                ApiBase::PARAM_TYPE => $wgImportSources
                        ),
@@ -150,7 +149,7 @@ class ApiImport extends ApiBase {
 
        public function getDescription() {
                return array(
-                       'Import a page from another wiki, or an XML file.' ,
+                       'Import a page from another wiki, or an XML file.',
                        'Note that the HTTP POST must be done as a file upload (i.e. using multipart/form-data) when',
                        'sending a file for the "xml" parameter.'
                );
@@ -178,7 +177,8 @@ class ApiImport extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'api.php?action=import&interwikisource=meta&interwikipage=Help:ParserFunctions&namespace=100&fullhistory=&token=123ABC'
+                       'api.php?action=import&interwikisource=meta&interwikipage=Help:ParserFunctions&' .
+                               'namespace=100&fullhistory=&token=123ABC'
                                => 'Import [[meta:Help:Parserfunctions]] to namespace 100 with full history',
                );
        }