Mediawiki developer tips

2020-10-08 14:14:46 +0200 +0200

Random things one learns as a MediaWiki developer. (I wish I started this two years ago.)

Version control your LocalSettings.php

By design, LocalSettings.php is not version controlled. You might be tempted to think you can keep track of the changes you’ve made and why. Better not to.

If you use core’s docker-compose environment, you can do something like:

mkdir -p localsettings; cp /path/to/core/LocalSettings.php localsettings/LocalSettings.php

Place the localsettings directory one level above mediawiki core, for example I have:

/home/kostajh/src/mediawiki/core
/home/kostajh/src/mediawiki/localsettings

Then change the contents LocalSettings.php in mediawiki/core to:

<?php
require_once "/localsettings/LocalSettings.php";

And in docker-compose.override.yml:

version: '3.7'
services:
  mediawiki:
    volumes:
    - ./:/var/www/html/w:cached
    - ../localsettings/LocalSettings.php:/localsettings/LocalSettings.php

In configuration, it’s common to see shorthand references to wikis, for example cs means cs.wikipedia.org. But if you try to use that in your local development environment, it won’t work until you run php maintenance/populateInterwiki.php. As its help message notes:

This script will populate the interwiki table, pulling in interwiki links that are used on Wikipedia
or another MediaWiki wiki.

You can then have a look at the interwiki table to see which aliases are supported.