Extension:InterwikiMap

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  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 InterwikiMap

 * Download the latest version of InterwikiMap (once it gets added to Git)
 * Create a folder in the extensions folder named InterwikiMap
 * Move the files to the extensions/InterwikiMap/ folder

Install InterwikiMap

 * Edit LocalSettings.php in the root of your MediaWiki installation, and add the following line near the bottom:

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

You may also want to set:

Usage
Your control of your interwiki table is by three means: (1) changing  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.

Whitelist
Adding an interwiki to your 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.

Blacklist
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
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.

Changelog

 * 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.