Documentation Index
Fetch the complete documentation index at: https://mintlify.com/wikioasis/mw-config/llms.txt
Use this file to discover all available pages before exploring further.
WikiFarmMultiVersion is a small but critical class in MultiVersion.php that provides a fast-path mechanism for per-wiki MediaWiki version overrides. While the farm’s primary version data lives in the databases.php CreateWiki cache, that cache is rebuilt asynchronously. WikiFarmMultiVersion bridges the gap by maintaining a lightweight PHP file — wikiVersions.php — that is read on every request and takes precedence over whatever is stored in the databases cache. This means a version change made through Special:ManageWiki/core is visible to the web server on the very next request, without waiting for a full cache regeneration.
The ManageWiki UI forms (
onManageWikiCoreAddFormFields / onManageWikiCoreFormSubmission) that surface the version selector are handled by MirahezeFunctions, not by this class. WikiFarmMultiVersion is solely responsible for the on-disk fast-path file.VERSIONS_FILE Constant
| Constant | Value |
|---|---|
VERSIONS_FILE | /srv/mediawiki/config/wikiVersions.php |
@include (suppressing errors on a missing file) and written atomically using a temp-file and rename().
File Format
Only wikis with a version different from the farm default appear in this file. When a wiki’s override is removed (by passing
null or the default version to setWikiVersion()), its entry is deleted from the file rather than set to the default value.Static Methods
getWikiVersion(string $dbname): string
getWikiVersion(string $dbname): string
Signature:
Returns:
public static function getWikiVersion( string $dbname ): stringReads wikiVersions.php and returns the stored version for $dbname. If the file does not exist, cannot be parsed, or does not contain an entry for $dbname, falls back to the farm default version by resolving:| Parameter | Type | Description |
|---|---|---|
$dbname | string | The wiki’s database name (e.g. examplewiki) |
string — A version number string such as '1.45' or '1.46'.Example:setWikiVersion(string $dbname, ?string $version): void
setWikiVersion(string $dbname, ?string $version): void
Signature:
Passing
public static function setWikiVersion( string $dbname, ?string $version ): voidAtomically writes a new version mapping for $dbname into wikiVersions.php. The write is performed using a process-specific temp file (wikiVersions.php.tmp.<pid>) that is then rename()d over the target, preventing any request from reading a partially-written file during concurrent access.After writing, the method invalidates the wiki’s per-wiki CreateWiki cache file (cw_cache/{dbname}.php) by deleting it, ensuring the next request rebuilds from fresh data.| Parameter | Type | Description |
|---|---|---|
$dbname | string | The wiki’s database name |
$version | string|null | The version string to set (e.g. '1.46'), or null to remove the override and revert to farm default |
null or the farm default removes the override entirely:onCreateWikiPhpBuilder(string $dbname, array &$cacheData): void
onCreateWikiPhpBuilder(string $dbname, array &$cacheData): void
Signature:
The injected
public static function onCreateWikiPhpBuilder( string $dbname, array &$cacheData ): voidThis is a hook handler for the CreateWikiPhpBuilder hook fired by the CreateWiki extension when it rebuilds the databases.php cache for a wiki. It reads wikiVersions.php and, if an override exists for $dbname, injects it as the 'v' key into $cacheData by reference. This keeps the databases cache in sync with the fast-path file so that MirahezeFunctions::getMediaWikiVersion() sees the same version regardless of which source it checks first.| Parameter | Type | Description |
|---|---|---|
$dbname | string | The wiki being rebuilt |
$cacheData | array& | The cache data array being written; modified in place |
'v' key overrides any version previously stored in the wiki_extra JSON column of cw_wikis.Integration with MirahezeFunctions
MirahezeFunctions::getMediaWikiVersion() checks wikiVersions.php before reading the databases.php cache, implementing this resolution chain:
Environment override
If the
MIRAHEZE_WIKI_VERSION environment variable is set, that value is used unconditionally.wikiVersions.php fast-path
wikiVersions.php is included and checked for the current database name. If found, that version is returned immediately — no cache file read is needed.databases.php cache
The
'v' key from the wiki’s entry in databases.php is used. This value is kept current by the onCreateWikiPhpBuilder hook.ManageWiki Integration
Version changes are surfaced to administrators via Special:ManageWiki/core, which shows a
mediawiki-version select field populated by onManageWikiCoreAddFormFields() in MirahezeFunctions. Only users with the managewiki-restricted right can change a wiki’s MediaWiki version.onManageWikiCoreFormSubmission() calls WikiFarmMultiVersion::setWikiVersion() for the immediate fast-path update, and also stores the value persistently via ManageWikiCore::setExtraFieldData() so it survives a full cache rebuild.