summaryrefslogtreecommitdiff
path: root/maintenance/importSiteScripts.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/importSiteScripts.php')
-rw-r--r--maintenance/importSiteScripts.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/maintenance/importSiteScripts.php b/maintenance/importSiteScripts.php
index 849c7b1b..0dc200ec 100644
--- a/maintenance/importSiteScripts.php
+++ b/maintenance/importSiteScripts.php
@@ -1,8 +1,11 @@
<?php
/**
- * Maintenance script to import all scripts in the MediaWiki namespace from a
+ * Maintenance script to import all scripts in the MediaWiki namespace from a
* local site.
+ * @file
+ * @ingroup Maintenance
*/
+
require_once( dirname( __FILE__ ) . '/Maintenance.php' );
class ImportSiteScripts extends Maintenance {
@@ -16,22 +19,29 @@ class ImportSiteScripts extends Maintenance {
public function execute() {
global $wgUser;
- $wgUser = User::newFromName( $this->getOption( 'username', 'ScriptImporter' ) );
+
+ $user = User::newFromName( $this->getOption( 'username', 'ScriptImporter' ) );
+ $wgUser = $user;
$baseUrl = $this->getArg( 1 );
$pageList = $this->fetchScriptList();
$this->output( 'Importing ' . count( $pageList ) . " pages\n" );
foreach ( $pageList as $page ) {
+ $title = Title::makeTitleSafe( NS_MEDIAWIKI, $page );
+ if ( !$title ) {
+ $this->error( "$page is an invalid title; it will not be imported\n" );
+ continue;
+ }
+
$this->output( "Importing $page\n" );
$url = wfAppendQuery( $baseUrl, array(
'action' => 'raw',
'title' => "MediaWiki:{$page}" ) );
$text = Http::get( $url );
-
- $title = Title::makeTitleSafe( NS_MEDIAWIKI, $page );
- $article = new Article( $title );
- $article->doEdit( $text, "Importing from $url", 0 );
+
+ $wikiPage = WikiPage::factory( $title );
+ $wikiPage->doEdit( $text, "Importing from $url", 0, false, $user );
}
}