summaryrefslogtreecommitdiff
path: root/includes/api/ApiImport.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
commit63601400e476c6cf43d985f3e7b9864681695ed4 (patch)
treef7846203a952e38aaf66989d0a4702779f549962 /includes/api/ApiImport.php
parent8ff01378c9e0207f9169b81966a51def645b6a51 (diff)
Update to MediaWiki 1.20.2
this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'includes/api/ApiImport.php')
-rw-r--r--includes/api/ApiImport.php42
1 files changed, 37 insertions, 5 deletions
diff --git a/includes/api/ApiImport.php b/includes/api/ApiImport.php
index ade9f1f3..637c1fff 100644
--- a/includes/api/ApiImport.php
+++ b/includes/api/ApiImport.php
@@ -4,7 +4,7 @@
*
* Created on Feb 4, 2009
*
- * Copyright © 2009 Roan Kattouw <Firstname>.<Lastname>@gmail.com
+ * Copyright © 2009 Roan Kattouw "<Firstname>.<Lastname>@gmail.com"
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -68,6 +68,12 @@ class ApiImport extends ApiBase {
if ( isset( $params['namespace'] ) ) {
$importer->setTargetNamespace( $params['namespace'] );
}
+ if ( isset( $params['rootpage'] ) ) {
+ $statusRootPage = $importer->setTargetRootPage( $params['rootpage'] );
+ if( !$statusRootPage->isGood() ) {
+ $this->dieUsageMsg( $statusRootPage->getErrorsArray() );
+ }
+ }
$reporter = new ApiImportReporter(
$importer,
$isUpload,
@@ -98,7 +104,10 @@ class ApiImport extends ApiBase {
public function getAllowedParams() {
global $wgImportSources;
return array(
- 'token' => null,
+ 'token' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => true
+ ),
'summary' => null,
'xml' => null,
'interwikisource' => array(
@@ -109,7 +118,8 @@ class ApiImport extends ApiBase {
'templates' => false,
'namespace' => array(
ApiBase::PARAM_TYPE => 'namespace'
- )
+ ),
+ 'rootpage' => null,
);
}
@@ -123,6 +133,18 @@ class ApiImport extends ApiBase {
'fullhistory' => 'For interwiki imports: import the full history, not just the current version',
'templates' => 'For interwiki imports: import all included templates as well',
'namespace' => 'For interwiki imports: import to this namespace',
+ 'rootpage' => 'Import as subpage of this page',
+ );
+ }
+
+ public function getResultProperties() {
+ return array(
+ ApiBase::PROP_LIST => true,
+ '' => array(
+ 'ns' => 'namespace',
+ 'title' => 'string',
+ 'revisions' => 'integer'
+ )
);
}
@@ -141,6 +163,8 @@ class ApiImport extends ApiBase {
array( 'cantimport-upload' ),
array( 'import-unknownerror', 'source' ),
array( 'import-unknownerror', 'result' ),
+ array( 'import-rootpage-nosubpage', 'namespace' ),
+ array( 'import-rootpage-invalid' ),
) );
}
@@ -186,8 +210,16 @@ class ApiImportReporter extends ImportReporter {
function reportPage( $title, $origTitle, $revisionCount, $successCount, $pageInfo ) {
// Add a result entry
$r = array();
- ApiQueryBase::addTitleInfo( $r, $title );
- $r['revisions'] = intval( $successCount );
+
+ if ( $title === null ) {
+ # Invalid or non-importable title
+ $r['title'] = $pageInfo['title'];
+ $r['invalid'] = '';
+ } else {
+ ApiQueryBase::addTitleInfo( $r, $title );
+ $r['revisions'] = intval( $successCount );
+ }
+
$this->mResultArr[] = $r;
// Piggyback on the parent to do the logging