From 1b8b24b932ecd2b3f6d7fe24119f27c3cb022308 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sun, 8 Jan 2012 20:42:22 +0000 Subject: [PATCH] * Use WikiPage instead of Article to call doEdit() * Pass the User doing the edit to doEdit() * Check for invalid title before fecthing content and doing the edit --- maintenance/importSiteScripts.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/maintenance/importSiteScripts.php b/maintenance/importSiteScripts.php index 849c7b1b8b..527b3bd4f2 100644 --- a/maintenance/importSiteScripts.php +++ b/maintenance/importSiteScripts.php @@ -16,22 +16,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 ); } } -- 2.20.1