Configuring multiple mediawiki instances within one file

It’s quite common to have multiple mediawiki instances. Not only for different wikis, also one productive wiki, one beta wiki, one test wiki, maybe all of those duplicated between webserver an localhost installations.

So far there are several tricks to handle the multiple configurations. I investigated the solution choosen by WikiMedia Foundation. It consists of one huge array containing all variables. Within the array, the various installations are either referenced by their direct name (“my_wiki_prod”), their “category” (“my_wiki”) or their “tags” (“wiki” or “locahost”). Even more, the variables can add to arrays (eg permissions).

Refer to WMF’s implementation for a very comprehensive example. They not only define the basic variables, they also set flags that are then used to load extension (or not)

However I found two flaws :

  • when merging arrays, if values are “false”, special care has to be taken : Values that evaluate to true given precedence, for the primary purpose of merging permissions arrays

  • Variable replacement is performed using the variables provided in an extra array argument. However, it was not possible to use variables that were defined using the configuration array. Something like setting $wgScript depending on $wgPath. modified the code, see the talk page of the $wgConf variable documentation.