Special:Version: Use addModuleStyles to load mediawiki.special.version
[lhc/web/wiklou.git] / maintenance / importSiteScripts.php
index e67d077..366594d 100644 (file)
@@ -32,7 +32,7 @@ require_once __DIR__ . '/Maintenance.php';
 class ImportSiteScripts extends Maintenance {
        public function __construct() {
                parent::__construct();
-               $this->mDescription = 'Import site scripts from a site';
+               $this->addDescription( 'Import site scripts from a site' );
                $this->addArg( 'api', 'API base url' );
                $this->addArg( 'index', 'index.php base url' );
                $this->addOption( 'username', 'User name of the script importer' );
@@ -41,7 +41,12 @@ class ImportSiteScripts extends Maintenance {
        public function execute() {
                global $wgUser;
 
-               $user = User::newFromName( $this->getOption( 'username', 'ScriptImporter' ) );
+               $username = $this->getOption( 'username', false );
+               if ( $username === false ) {
+                       $user = User::newSystemUser( 'ScriptImporter', array( 'steal' => true ) );
+               } else {
+                       $user = User::newFromName( $username );
+               }
                $wgUser = $user;
 
                $baseUrl = $this->getArg( 1 );
@@ -59,7 +64,7 @@ class ImportSiteScripts extends Maintenance {
                        $url = wfAppendQuery( $baseUrl, array(
                                'action' => 'raw',
                                'title' => "MediaWiki:{$page}" ) );
-                       $text = Http::get( $url );
+                       $text = Http::get( $url, array(), __METHOD__ );
 
                        $wikiPage = WikiPage::factory( $title );
                        $content = ContentHandler::makeContent( $text, $wikiPage->getTitle() );
@@ -81,7 +86,7 @@ class ImportSiteScripts extends Maintenance {
 
                while ( true ) {
                        $url = wfAppendQuery( $baseUrl, $data );
-                       $strResult = Http::get( $url );
+                       $strResult = Http::get( $url, array(), __METHOD__ );
                        $result = FormatJson::decode( $strResult, true );
 
                        $page = null;