From: Alexandre Emsenhuber Date: Sun, 8 Jan 2012 20:42:22 +0000 (+0000) Subject: * Use WikiPage instead of Article to call doEdit() X-Git-Tag: 1.31.0-rc.0~25421 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=1b8b24b932ecd2b3f6d7fe24119f27c3cb022308;p=lhc%2Fweb%2Fwiklou.git * 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 --- 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 ); } }