From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png

Release status:Extension status beta

ImplementationTemplate:Extension#type Special page
DescriptionTemplate:Extension#description Updates the local interwiki table with the contents of an interwiki map retrieved from another wiki
Author(s)Template:Extension#username (Leucostictetalk)
Latest versionTemplate:Extension#version 1.0.6
MediaWikiTemplate:Extension#mediawiki 1.20+
LicenseTemplate:Extension#license GNU General Public License 3.0 or later
ExampleTemplate:Extension#example http://wiki.mises.org/

$wgInterwikiMapSeconds $wgInterwikiMapMinimumSeconds $wgInterwikiMapOdds $wgInterwikiMapWhitelistPage $wgInterwikiMapBlacklistPage $wgInterwikiMapRemoteWikiUrls $wgInterwikiMapApiArgs $wgInterwikiMapUserAgent $wgInterwikiMapBackupPage $wgInterwikiMapBackupDescPage $wgInterwikiMapBackupText $wgInterwikiMapBackupUser $wgInterwikiMapBackupSummary

Hooks usedTemplate:Extension#hook

Translate the InterwikiMap extension if it is available at translatewiki.net

Check usage and version matrix.

InterwikiMap updates the local interwiki table with the contents of an interwiki map retrieved from other wiki(s). It can be configured to update the table every x seconds and/or when authorized users trigger it via Special:InterwikiMap. It also automatically updates whenever MediaWiki:Interwiki-whitelist or MediaWiki:Interwiki-blacklist are revised. The whitelist contains a map of pages that will be added to, and remain in, the interwiki table regardless of the maps retrieved from the remote wikis. The blacklist contains a map of pages that will be removed from the interwiki table. Every time the table is updated by this extension, MediaWiki:InterwikiMapBackup is updated by the maintenance script. Thus, you keep a page history of all changes to the interwiki table.

You can select whatever wikis you want to poll; if you select more than one, it will poll all of them and merge all the lists together, resolving any conflicts in favor of the wikis later in the $wgInterwikiMapRemoteWikiUrls array. If retrieval or decoding of the results of the siprop=interwikimap API module fails on any of them, the entire update will be aborted; this is because you need the entire combined list in order to know which interwiki links to remove from the local interwiki table.

Please note, if you are setting up wiki X to poll wiki Y, you only need to install the extension on wiki X. Wiki Y's MediaWiki core functionality already includes the necessary API module to enable it to respond to wiki x's polling. Due to recent extensive revisions and a lack of thorough testing thus far, this extension is considered experimental at this time.


  • Download and place the file(s) in a directory called InterwikiMap in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/InterwikiMap/InterwikiMap.php";
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


Change these settings to your liking, making sure that you include them in LocalSettings.php after the require_once line installing the extension.

// Update the interwiki map every 86400 seconds (24 hours). Be kind to the remote wiki's servers
// by not putting too low a value (e.g. less than 900 seconds) for this.
$wgInterwikiMapSeconds = 86400;
// Absolute minimum seconds between refreshes triggered by special page; 'interwikimapnoratelimit'
// users are exempt
$wgInterwikiMapMinimumSeconds = 60;
// x in 360 chance, upon an edit being saved, of checking to see whether it's time to update the
// interwiki map; if your wiki gets a lot of edits (e.g. more than one every 24 hours), set this
// to less than 360 to reduce database load. E.g. 36 would be a 10% chance. Change to 0 if you
// want to make it never check; e.g. if you only want to manually trigger updates.
$wgInterwikiMapOdds = 360;
// Prefixes on this list will be added to the interwiki list and will not be removed from it.
// However, the URLs will be overridden by any URLs provided by the remote wiki, unless a URL is
// provided in this table.
$wgInterwikiMapWhitelistPage = 'MediaWiki:Interwiki-whitelist';
// Prefixes on this list will be removed from the interwiki list and will not be added to it.
// However, the whitelist overrides the blacklist where there is any conflict.
$wgInterwikiMapBlacklistPage = 'MediaWiki:Interwiki-blacklist';
// This is the URL, or array or URLs, from which to obtain interwiki maps. If one is inaccessible,
// then the table will not be updated this time around, and a notice will be issued. Otherwise, the
// maps will be merged, with wikis listed later in the array overwriting values on maps of wikis
// listed earlier in the array.
$wgInterwikiMapRemoteWikiUrls = 'https://meta.wikimedia.org/w/api.php';
// Arguments to use when accessing the API
$wgInterwikiMapApiArgs = '?action=query&meta=siteinfo&siprop=interwikimap&format=json';
// The user-agent to use in requests to the wikis from which the interwiki maps are obtained
$wgInterwikiMapUserAgent = "User-Agent: $wgSitename's InterwikiMap. Contact info: URL: "
        . $wgServer . $wgScriptPath . " Email: $wgEmergencyContact";
// MediaWiki: page in which to store copies of the interwiki table; set to false to disable
$wgInterwikiMapBackupPage = 'MediaWiki:InterwikiMapBackup';
// MediaWiki: description page for the backup page
$wgInterwikiMapBackupDescPage = 'MediaWiki:interwikimap-backup-desc';
// Text with which to begin the backup page; if blank, will use a default
$wgInterwikiMapBackupText = '';
// Username of user who edits the backup page
$wgInterwikiMapBackupUser = 'Maintenance script';
// Edit summary for editing the backup page
$wgInterwikiMapBackupSummary = 'Robot: $1';
// Sysops can manually trigger the update
$wgGroupPermissions['sysop']['interwikimap'] = true;
// Bureaucrats can manually trigger the update without being throttled
$wgGroupPermissions['bureaucrat']['interwikimapnoratelimit'] = true;

You may also want to set:

// We don't want sysops	changing the interwiki table directly; they should use the
// MediaWiki:Interwiki-whitelist and MediaWiki:Interwiki-blacklist
$wgGroupPermissions['sysop']['interwiki'] = false;


Your control of your interwiki table is by three means: (1) changing $wgInterwikiMapRemoteWikiUrls and the other configuration settings; (2) editing your whitelist; and (3) editing your blacklist. Doing either of the latter two, or visiting Special:InterwikiMap, will cause the remote wikis to be polled and the interwiki table to be updated if necessary. Also, when other pages on your wiki are revised, a check will be done to see whether it's time for the periodic polling of the remote wikis.

The only fields it will retrieve from the remote API are prefix, URL, API URL, and wiki ID. The forward and transclude are up to you to set via the whitelist.


Adding an interwiki to your whitelist (MediaWiki:Interwiki-whitelist) will add it to your interwiki table, regardless of what is on the remote wiki's interwiki map (or on your own blacklist). Whitelist entries are listed in this format, in which any line that doesn't start with a | will be ignored, and the || indicates the break between prefix and url:

| wikipedia || https://en.wikipedia.org/wiki/$1

If you want, you can put the desired values for iw_local (forward), iw_trans (transclude), iw_api (API URL), and iw_wikiid (wiki ID) as well, in that order:

| wikipedia || https://en.wikipedia.org/wiki/$1 || 1 || 1 || https://en.wikipedia.org/w/api.php || enwiki

In some cases, the whitelist will cause different effects if you leave a field blank than if you omit that field entirely. In the case of iw_local and iw_trans, leaving it blank or omitting it have the same effect, viz. the data will be pulled from the API, or left as it is in the database if it can't be pulled from the API. In the case of API url and wiki ID, blank means delete the contents in the interwiki table and omitted means pull it from the API, or leave it as it is in the database if it can't be pulled from the API. The prefix and API are mandatory.

Results of various inputs to the whitelist
Option Field
iw_prefix iw_url iw_local iw_trans iw_api iw_wikiid
Omit N/A; mandatory N/A; mandatory Value already stored in database Value already stored in database Value pulled from API; if unavailable, value already stored in database Value pulled from API; if unavailable, value already stored in database
Blank N/A; mandatory N/A; mandatory Value already stored in database Value already stored in database Blank Blank


Adding an interwiki prefix to your blacklist will remove it from your interwiki table, regardless of what is on the remote wiki's interwiki map. Only put the prefix (not the url):

| wikipedia

Backup page[edit]

MediaWiki:InterwikiMapBackup is only supposed to be edited by the maintenance script (although it won't break anything if someone else edits it, it'll leave you with a useless revision in the history that doesn't reflect an actual change to the interwiki table). Therefore, you might want to change $wgInterwikiMapBackupPage to instead use a page outside the MediaWiki: namespace (e.g. to Project: or mainspace), revise the settings in $wgRestrictionLevels accordingly, and protect the page from editing by well-being sysops. You might also put explanatory notes at MediaWiki:Editnotice-8-InterwikiMap‎‎Backup (or whatever would be the appropriate page; see Help:Edit notice), MediaWiki:Editnotice-8-Interwiki-whitelist, and MediaWiki:Editnotice-8-Interwiki-blacklist.


  • 1.06: Make compatible with MW v1.21
  • 1.05: Get rid of code for nonexistent interwiki table
  • 1.04: Added support for iw_local (forward), iw_trans (transclude), iw_api (API URL), and iw_wikiid (wiki ID).
  • 1.03: Made Special:InterwikiMap a restricted special page. Added option for $wgInterwikiMapRemoteWikiUrls to be a string rather than an array. Added support for MediaWiki 1.21's Revision::getContent( Revision::RAW ). Fix deletion summary comma bug.
  • 1.02: Added a check to make sure that interwiki prefixes that conflict with namespaces aren't added.

See also[edit]