https://www.mediawiki.org/wiki/Special:Code/MediaWiki/108365

Revision: 108365
Author:   ialex
Date:     2012-01-08 20:42:22 +0000 (Sun, 08 Jan 2012)
Log Message:
-----------
* 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

Modified Paths:
--------------
    trunk/phase3/maintenance/importSiteScripts.php

Modified: trunk/phase3/maintenance/importSiteScripts.php
===================================================================
--- trunk/phase3/maintenance/importSiteScripts.php      2012-01-08 20:40:13 UTC 
(rev 108364)
+++ trunk/phase3/maintenance/importSiteScripts.php      2012-01-08 20:42:22 UTC 
(rev 108365)
@@ -16,22 +16,29 @@
        
        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 );
                }
                
        }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to