Index: trunk/phase3/maintenance/importSiteScripts.php |
— | — | @@ -16,22 +16,29 @@ |
17 | 17 | |
18 | 18 | public function execute() { |
19 | 19 | global $wgUser; |
20 | | - $wgUser = User::newFromName( $this->getOption( 'username', 'ScriptImporter' ) ); |
| 20 | + |
| 21 | + $user = User::newFromName( $this->getOption( 'username', 'ScriptImporter' ) ); |
| 22 | + $wgUser = $user; |
21 | 23 | |
22 | 24 | $baseUrl = $this->getArg( 1 ); |
23 | 25 | $pageList = $this->fetchScriptList(); |
24 | 26 | $this->output( 'Importing ' . count( $pageList ) . " pages\n" ); |
25 | 27 | |
26 | 28 | foreach ( $pageList as $page ) { |
| 29 | + $title = Title::makeTitleSafe( NS_MEDIAWIKI, $page ); |
| 30 | + if ( !$title ) { |
| 31 | + $this->error( "$page is an invalid title; it will not be imported\n" ); |
| 32 | + continue; |
| 33 | + } |
| 34 | + |
27 | 35 | $this->output( "Importing $page\n" ); |
28 | 36 | $url = wfAppendQuery( $baseUrl, array( |
29 | 37 | 'action' => 'raw', |
30 | 38 | 'title' => "MediaWiki:{$page}" ) ); |
31 | 39 | $text = Http::get( $url ); |
32 | | - |
33 | | - $title = Title::makeTitleSafe( NS_MEDIAWIKI, $page ); |
34 | | - $article = new Article( $title ); |
35 | | - $article->doEdit( $text, "Importing from $url", 0 ); |
| 40 | + |
| 41 | + $wikiPage = WikiPage::factory( $title ); |
| 42 | + $wikiPage->doEdit( $text, "Importing from $url", 0, false, $user ); |
36 | 43 | } |
37 | 44 | |
38 | 45 | } |