dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "FeedbackDialog: Improve alignment"
[lhc/web/wiklou.git]
/
maintenance
/
importSiteScripts.php
diff --git
a/maintenance/importSiteScripts.php
b/maintenance/importSiteScripts.php
index
6566a60
..
7fdb355
100644
(file)
--- a/
maintenance/importSiteScripts.php
+++ b/
maintenance/importSiteScripts.php
@@
-32,7
+32,7
@@
require_once __DIR__ . '/Maintenance.php';
class ImportSiteScripts extends Maintenance {
public function __construct() {
parent::__construct();
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' );
$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;
public function execute() {
global $wgUser;
- $user = User::newFromName( $this->getOption( 'username', 'ScriptImporter' ) );
+ $username = $this->getOption( 'username', false );
+ if ( $username === false ) {
+ $user = User::newSystemUser( 'ScriptImporter', [ 'steal' => true ] );
+ } else {
+ $user = User::newFromName( $username );
+ }
$wgUser = $user;
$baseUrl = $this->getArg( 1 );
$wgUser = $user;
$baseUrl = $this->getArg( 1 );
@@
-56,10
+61,10
@@
class ImportSiteScripts extends Maintenance {
}
$this->output( "Importing $page\n" );
}
$this->output( "Importing $page\n" );
- $url = wfAppendQuery( $baseUrl,
array(
+ $url = wfAppendQuery( $baseUrl,
[
'action' => 'raw',
'action' => 'raw',
- 'title' => "MediaWiki:{$page}"
)
);
- $text = Http::get( $url,
array()
, __METHOD__ );
+ 'title' => "MediaWiki:{$page}"
]
);
+ $text = Http::get( $url,
[]
, __METHOD__ );
$wikiPage = WikiPage::factory( $title );
$content = ContentHandler::makeContent( $text, $wikiPage->getTitle() );
$wikiPage = WikiPage::factory( $title );
$content = ContentHandler::makeContent( $text, $wikiPage->getTitle() );
@@
-68,20
+73,20
@@
class ImportSiteScripts extends Maintenance {
}
protected function fetchScriptList() {
}
protected function fetchScriptList() {
- $data =
array(
+ $data =
[
'action' => 'query',
'format' => 'json',
'list' => 'allpages',
'apnamespace' => '8',
'aplimit' => '500',
'continue' => '',
'action' => 'query',
'format' => 'json',
'list' => 'allpages',
'apnamespace' => '8',
'aplimit' => '500',
'continue' => '',
-
)
;
+
]
;
$baseUrl = $this->getArg( 0 );
$baseUrl = $this->getArg( 0 );
- $pages =
array()
;
+ $pages =
[]
;
while ( true ) {
$url = wfAppendQuery( $baseUrl, $data );
while ( true ) {
$url = wfAppendQuery( $baseUrl, $data );
- $strResult = Http::get( $url,
array()
, __METHOD__ );
+ $strResult = Http::get( $url,
[]
, __METHOD__ );
$result = FormatJson::decode( $strResult, true );
$page = null;
$result = FormatJson::decode( $strResult, true );
$page = null;