24require_once __DIR__ .
'/Maintenance.php';
34 parent::__construct();
36 $this->
addArg(
'api',
'API base url' );
37 $this->
addArg(
'index',
'index.php base url' );
38 $this->
addOption(
'username',
'User name of the script importer' );
46 $user = User::newSystemUser(
'ScriptImporter', [
'steal' =>
true ] );
52 $baseUrl = $this->
getArg( 1 );
54 $this->
output(
'Importing ' . count( $pageList ) .
" pages\n" );
56 foreach ( $pageList as $page ) {
57 $title = Title::makeTitleSafe( NS_MEDIAWIKI, $page );
59 $this->
error(
"$page is an invalid title; it will not be imported\n" );
63 $this->
output(
"Importing $page\n" );
66 'title' =>
"MediaWiki:{$page}" ] );
67 $text = Http::get( $url, [], __METHOD__ );
71 $wikiPage->doEditContent( $content,
"Importing from $url", 0,
false, $user );
84 $baseUrl = $this->
getArg( 0 );
89 $strResult = Http::get( $url, [], __METHOD__ );
90 $result = FormatJson::decode( $strResult,
true );
93 foreach ( $result[
'query'][
'allpages'] as $page ) {
94 if ( substr( $page[
'title'], -3 ) ===
'.js' ) {
95 strtok( $page[
'title'],
':' );
96 $pages[] = strtok(
'' );
100 if ( $page !==
null ) {
101 $this->
output(
"Fetched list up to {$page['title']}\n" );
104 if ( isset( $result[
'continue'] ) ) {
105 $data = array_replace( $data, $result[
'continue'] );
106 } elseif ( isset( $result[
'query-continue'][
'allpages'] ) ) {
107 $data = array_replace( $data, $result[
'query-continue'][
'allpages'] );
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Maintenance script to import all scripts in the MediaWiki namespace from a local site.
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true)
Add some args that are needed.
getArg( $argId=0, $default=null)
Get an argument.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
this hook is for auditing only or null if authentication failed before getting that far $username
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
require_once RUN_MAINTENANCE_IF_MAIN