aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiImport.php
diff options
context:
space:
mode:
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>2015-09-23 16:30:36 +0000
committerGerrit Code Review <gerrit@wikimedia.org>2015-09-23 16:30:36 +0000
commit70e760ee4e37edad1be0573b37c17fe6899e4806 (patch)
treec6f7a6b3985d7e2bf32d0187c5c3c90ee90f5206 /includes/api/ApiImport.php
parentf7a07da7a86f9f18990a2c80eddd2de9c604208c (diff)
parentd3b85592ead7fc1348c20c565fd21375da5417de (diff)
downloadmediawikicore-70e760ee4e37edad1be0573b37c17fe6899e4806.tar.gz
mediawikicore-70e760ee4e37edad1be0573b37c17fe6899e4806.zip
Merge "Add hook to allow lazy loading of import sources"
Diffstat (limited to 'includes/api/ApiImport.php')
-rw-r--r--includes/api/ApiImport.php26
1 files changed, 25 insertions, 1 deletions
diff --git a/includes/api/ApiImport.php b/includes/api/ApiImport.php
index 735cc7fa1133..a6aae4bb1c3d 100644
--- a/includes/api/ApiImport.php
+++ b/includes/api/ApiImport.php
@@ -92,6 +92,30 @@ class ApiImport extends ApiBase {
$result->addValue( null, $this->getModuleName(), $resultData );
}
+ /**
+ * Returns a list of interwiki prefixes corresponding to each defined import
+ * source.
+ *
+ * @return array
+ * @since 1.26
+ */
+ public function getAllowedImportSources() {
+ $importSources = $this->getConfig()->get( 'ImportSources' );
+ Hooks::run( 'ImportSources', array( &$importSources ) );
+
+ $result = array();
+ foreach ( $importSources as $key => $value ) {
+ if ( is_int( $key ) ) {
+ $result[] = $value;
+ } else {
+ foreach ( $value as $subproject ) {
+ $result[] = "$key:$subproject";
+ }
+ }
+ }
+ return $result;
+ }
+
public function mustBePosted() {
return true;
}
@@ -107,7 +131,7 @@ class ApiImport extends ApiBase {
ApiBase::PARAM_TYPE => 'upload',
),
'interwikisource' => array(
- ApiBase::PARAM_TYPE => $this->getConfig()->get( 'ImportSources' ),
+ ApiBase::PARAM_TYPE => $this->getAllowedImportSources(),
),
'interwikipage' => null,
'fullhistory' => false,