29require_once __DIR__ .
'/Maintenance.php';
39 parent::__construct();
42This script will populate the interwiki
table, pulling in interwiki
links that are used on
Wikipedia
45When the script has finished, it will make a note of
this in the database, and will not run again
46without the --force option.
48--source parameter is the url
for the source wiki api, such as
"https://en.wikipedia.org/w/api.php"
49(the
default) from which the script fetches the interwiki data and uses here to populate
50the interwiki database
table.
54 $this->
addOption(
'source',
'Source wiki for interwiki table, such as '
55 .
'https://en.wikipedia.org/w/api.php (the default)',
false,
true );
56 $this->
addOption(
'force',
'Run regardless of whether the database says it has '
57 .
'been run already.' );
62 $this->source = $this->
getOption(
'source',
'https://en.wikipedia.org/w/api.php' );
66 if ( $data ===
false ) {
67 $this->
error(
"Error during fetching data." );
80 'siprop' =>
'interwikimap',
81 'sifilteriw' =>
'local',
85 if ( !empty( $this->source ) ) {
86 $url = rtrim( $this->source,
'?' ) .
'?' . $url;
90 $data = json_decode( $json,
true );
92 if ( is_array( $data ) ) {
93 return $data[
'query'][
'interwikimap'];
109 $row = $dbw->selectRow(
112 [
'ul_key' =>
'populate interwiki' ],
117 $this->
output(
"Interwiki table already populated. Use php " .
118 "maintenance/populateInterwiki.php\n--force from the command line " .
124 $lookup = MediaWikiServices::getInstance()->getInterwikiLookup();
125 foreach ( $data as $d ) {
126 $prefix = $d[
'prefix'];
128 $row = $dbw->selectRow(
131 [
'iw_prefix' => $prefix ],
139 'iw_prefix' => $prefix,
140 'iw_url' => $d[
'url'],
148 $lookup->invalidateCache( $prefix );
151 $this->
output(
"Interwiki links are populated.\n" );
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
static get( $url, $options=[], $caller=__METHOD__)
Simple wrapper for Http::request( 'GET' )
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular option exists.
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.
execute()
Do the actual work.
__construct()
Default constructor.
doPopulate(array $data, $force)
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if so it s not worth the trouble Since there is a job queue in the jobs table
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
require_once RUN_MAINTENANCE_IF_MAIN
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like Wikipedia
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
This document describes the XML format used to represent information about external sites known to a MediaWiki installation This information about external sites is used to allow inter wiki links
in the order they appear.