Skip to main content

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.

MirahezeFunctions is the single most important PHP class in the WikiOasis farm. Instantiated once per request inside LocalSettings.php as $wi = new MirahezeFunctions(), it bootstraps the entire wiki context — detecting the current database name, resolving the correct MediaWiki version, loading per-wiki configuration from the CreateWiki cache, populating SiteConfiguration settings, and queueing extension files. Every other configuration file in the farm depends on the state it produces. Understanding this class means understanding how WikiOasis works from the inside out.

Constants

Constants marked public are accessible from outside the class. Constants marked private are used internally and listed here for documentation purposes only.
ConstantVisibilityValueDescription
ALLOWED_DOMAINS['default']private['wikioasis.org', 'skywiki.org']Production domains accepted as valid wiki suffixes
ALLOWED_DOMAINS['beta']private['betaoasis.xyz']Beta/staging domains
BETA_HOSTNAMEprivate'staging11'Hostname of the beta server; used to detect realm
CACHE_DIRECTORYpublic'/srv/mediawiki/cw_cache'Directory where CreateWiki and config cache files live
CONFIG_DIRECTORYprivate'/srv/mediawiki/config'Directory containing LocalSettings.php and related files
CENTRAL_DATABASE['default']private'metawiki'Central wiki DB for production
CENTRAL_DATABASE['beta']private'metawikibeta'Central wiki DB for beta
DEFAULT_SERVER['default']private'wikioasis.org'Default domain for production wikis
DEFAULT_SERVER['beta']private'betaoasis.xyz'Default domain for beta wikis
SHARED_DOMAIN['default']private'accounts.wikioasis.org'CentralAuth shared login domain (production)
SHARED_DOMAIN['beta']private'accounts.betaoasis.xyz'CentralAuth shared login domain (beta)
GLOBAL_DATABASE['default']private'wikidb'Global cross-wiki database (production)
GLOBAL_DATABASE['beta']private'wikidbbeta'Global cross-wiki database (beta)
MEDIAWIKI_DIRECTORYprivate'/srv/mediawiki/versions'Root of versioned MediaWiki installs
MEDIAWIKI_VERSIONS['alpha']public'1.46'Alpha MediaWiki branch
MEDIAWIKI_VERSIONS['beta']public'1.45'Beta MediaWiki branch
MEDIAWIKI_VERSIONS['stable']public'1.45'Stable MediaWiki branch (farm default)
SUFFIXES['wiki']public['wikioasis.org', 'skywiki.org']DB suffix → accepted domains mapping (production)
SUFFIXES['wikibeta']public['betaoasis.xyz']DB suffix → accepted domains mapping (beta)

Public Properties

These are declared public readonly on the instance ($wi) created in LocalSettings.php.
dbname
string
The database name for the current wiki (e.g. examplewiki). Resolved by getCurrentDatabase() during construction and immutable thereafter.
realm
string
Either 'default' (production) or 'beta'. Derived from whether $dbname ends with the wiki or wikibeta suffix.
server
string
The full HTTPS server URL for the current wiki (e.g. https://example.wikioasis.org). Resolved by getServer() during construction.
sitename
string
The human-readable site name of the current wiki (e.g. "My Example Wiki"). Resolved from the CreateWiki cache during construction.
version
string
The MediaWiki version string active for this wiki (e.g. '1.45'). Resolved by getMediaWikiVersion() during construction.
wikiDBClusters
array
A map of dbname => cluster for all known wikis (including deleted). Populated from both databases.php and deleted.php cache files.
missing
bool
true if the current wiki does not appear in $wgConf->wikis. When true, the farm has already served a 410 error page — this property is informational for downstream code.

Public Static Properties

$disabledExtensions
array
A globally writeable map of extensionKey => reason for extensions that have been globally disabled by administrators. Populated before loadExtensions() runs; handleDisabledExtensions() uses it to annotate the ManageWiki UI and prevent re-enabling.

Static Methods

getLocalDatabases()
static: array
Returns the merged list of all active and deleted database names. Sets $wgLocalDatabases as a side effect. Uses a static cache so it is only computed once per process. Called by setupSiteConfiguration().
readDbListFile(string $listFile, bool $onlyDBs = true, ?string $database = null, bool $fromServer = false)
static: array|string
Reads a PHP cache file from CACHE_DIRECTORY (e.g. databases.php, deleted.php). When $database is provided and $fromServer is true, reverse-looks up a DB name from a server URL. When $onlyDBs is true, returns a flat array of DB name strings; otherwise returns the full associative data array. Returns [] when the cache file is missing or empty. Respects $wgDatabaseClustersMaintenance — if the current wiki’s cluster is in maintenance, it calls DatabaseMaintenance.php immediately.
getRealm(?string $database = null)
static: string
Returns 'default' if $database ends with the wiki suffix, or 'beta' otherwise. Defaults to the current database when $database is null.
getCurrentSuffix()
static: string
Detects which DB suffix is active by comparing the realm’s default server against the SUFFIXES map. Returns 'wiki' for production, 'wikibeta' for beta, with 'wiki' as a hard fallback.
getCurrentDatabase(bool $ignorePrimary = false)
static: string
Returns the current wiki’s database name using several resolution strategies in order: (1) MW_DB constant (CLI), (2) shared-domain path prefix (accounts.wikioasis.org), (3) reverse lookup via databases.php cache, (4) subdomain + suffix decomposition from HTTP_HOST. Returns an empty string if resolution fails.
getDatabaseClusters()
static: array
Returns a flat map of dbname => cluster for every wiki in both databases.php and deleted.php. Used to populate $wi->wikiDBClusters.
getPrimaryDomain(string $database)
static: string
Reads the 'd' key from databases.php for $database. Falls back to DEFAULT_SERVER[realm] if no custom primary domain is stored.
getServers(?string $database = null, bool $deleted = false)
static: array|string
When $database is provided, returns the single server URL string for that wiki. When null, returns the full dbname => URL map for all wikis. Respects custom domains stored in the 'u' key and primary domains in the 'd' key of the cache. Includes deleted wikis in the map when $deleted is true.
getDefaultServer(?string $database = null)
static: string
Returns the plain domain string (without scheme) for the realm’s default server — 'wikioasis.org' or 'betaoasis.xyz'.
getServer()
static: string
Returns the server URL for the current wiki by calling getServers() with the current database name. Used to set $wi->server during construction.
getSiteNames()
static: array
Returns a dbname => sitename map for all wikis (active + deleted), sourced from the 's' key in cache files. Includes a 'default' key set to 'No sitename set.'.
getSiteName()
static: string
Returns the site name for the current wiki by looking up getSiteNames() with $currentDatabase. Falls back to the 'default' entry.
getDefaultMediaWikiVersion()
static: string
Returns the string key ('stable' or 'beta') that identifies the farm default version. Returns 'beta' on the staging11 host when that key exists in MEDIAWIKI_VERSIONS, otherwise 'stable'.
getMediaWikiVersion(?string $database = null)
static: string
Resolves the MediaWiki version string for a wiki. Resolution order: (1) MIRAHEZE_WIKI_VERSION environment variable, (2) wikiVersions.php fast-path file, (3) 'v' key in databases.php cache, (4) farm default. Also handles CLI version detection from SCRIPT_NAME path depth. Returns a version number string like '1.45'.
getMediaWiki(string $file)
static: string
Resolves the full filesystem path to a file under the active MediaWiki version directory. Sets $IP and MW_INSTALL_PATH as side effects. Returns a path like /srv/mediawiki/versions/1.45/index.php.
getCacheArray()
static: array
Reads the per-wiki CreateWiki cache file at CACHE_DIRECTORY/{dbname}.php. Returns the full PHP array (containing core, states, settings, namespaces, permissions, extensions keys) or [] if not found.
getConfigGlobals()
static: array
The main configuration resolver. Tries to read a pre-built config from config-{dbname}.php in the cache directory; if stale or absent, it merges the ManageWiki config cache into $wgConf->settings, resolves all globals via getConfigForCaching(), writes the result back to cache, and returns the globals array. Cache validity is determined by mtime comparison against LocalSettings.php, ManageWikiExtensions.php, ManageWikiNamespaces.php, ManageWikiSettings.php, Defines.php, and the per-wiki cache file.
getConfigForCaching()
static: array
Builds the resolved configuration array by calling $wgConf->getAll() with the current wiki’s suffix, language, site params, and all active wiki tags (realm, MW version, states, active extensions as ext-* prefixed tags).
writeToCache(string $cacheShard, array $configObject)
static: void
Atomically writes a PHP cache file to CACHE_DIRECTORY. Uses tempnam() + rename() to prevent partial reads. Calls opcache_invalidate() after writing to ensure the new content is picked up immediately.
readFromCache(string $confCacheFile, string $type, int $confActualMtime)
static: array|null
Reads a cache shard file and returns the value at key $type if the stored mtime matches $confActualMtime. Returns null on a cache miss or stale entry.
ParameterTypeDescription
$confCacheFilestringFull path to the config cache file
$typestringKey to extract ('globals' or 'extensions')
$confActualMtimeintExpected modification timestamp
getManageWikiConfigCache()
static: array
Translates the CreateWiki cache array into a $wgConf->settings-compatible array. Handles: language code, wiki states (cwPrivate, cwClosed, etc.), per-wiki settings, namespace definitions (searchable, subpages, content model, protection, aliases, extra namespaces), and group permissions (permissions, addgroups, removegroups, autopromote/autopromoteonce).
getCacheDirectory()
static: string
Returns the CACHE_DIRECTORY constant value ('/srv/mediawiki/cw_cache'). A stable accessor for code that needs the cache path without referencing the constant directly.
getActiveExtensions(bool $useConfigCache = true)
static: array
Returns the list of extension names currently enabled for the wiki, after filtering out any globally disabled extensions from $disabledExtensions. When $useConfigCache is true, tries to return the 'extensions' key from the config cache before falling back to a full computation against $wgManageWikiExtensions and the CreateWiki cache.
handleDisabledExtensions()
static: void
Iterates over $disabledExtensions and, for each entry, injects a bold note into the ManageWiki UI help text and restricts the extension to require managewiki-restricted to re-enable. Called by loadExtensions() before the extension queue is built.
onGenerateDatabaseLists(array &$databaseLists)
static: void
Hook handler for GenerateDatabaseLists. Queries cw_wikis directly via the global database and builds the complete set of named lists — active, closed, databases, deleted, inactive, public, private, and per-version lists (stable-wikis, beta-wikis, alpha-wikis). Writes into $databaseLists by reference.
onManageWikiCoreAddFormFields(IContextSource $context, ModuleFactory $moduleFactory, string $dbname, bool $ceMW, array &$formDescriptor)
static: void
Hook handler that injects two fields into the Special:ManageWiki/core form: a primary-domain select (restricted to managewiki-restricted) and a mediawiki-version select (filtered to only show versions that exist on disk). Both fields default to the wiki’s current values.
onManageWikiCoreFormSubmission(IContextSource $context, ModuleFactory $moduleFactory, string $dbname, array $formData)
static: void
Hook handler that persists mediawiki-version and primary-domain changes submitted via Special:ManageWiki/core. For version changes, calls WikiFarmMultiVersion::setWikiVersion() for immediate effect and stores the new value via ManageWikiCore::setExtraFieldData().
onMediaWikiServices()
static: void
Hook handler for MediaWikiServices. Applies the resolved config globals to $GLOBALS by iterating over the globals array set during bootstrap. Skips keys that have a + merge variant in $wgConf->settings, and always skips wgArticlePath, wgServer, and wgManageWikiPermissionsAdditionalRights. Unsets $GLOBALS['globals'] when done.
isMissing()
static: bool
Returns true if the current database is not present in $wgConf->wikis. This indicates the wiki does not exist in the CreateWiki registry and error handling should take over.
setupSiteConfiguration()
static: void
Initializes $wgConf as a new SiteConfiguration instance, sets $wgConf->suffixes from the SUFFIXES constant keys, and populates $wgConf->wikis by calling getLocalDatabases(). Called at the very beginning of the constructor.

Instance Methods

These methods are called on the $wi instance object.
__construct()
void
Initializes the full wiki context in a fixed sequence:
  1. Calls setupSiteConfiguration() to prepare $wgConf.
  2. Resolves $this->dbname via getCurrentDatabase().
  3. Validates that the DB suffix matches the expected realm for the current server; exits with a 410 or CLI error if not.
  4. Populates $this->wikiDBClusters from getDatabaseClusters().
  5. Sets $this->server, $this->sitename, $this->missing, $this->realm, and $this->version.
  6. Calls setDatabase(), setServers(), and setSiteNames() to propagate values into $wgConf.
getAllowedDomains()
array
Returns the list of allowed domains for the current realm — ['wikioasis.org', 'skywiki.org'] in production or ['betaoasis.xyz'] in beta.
getCentralDatabase()
string
Returns 'metawiki' (production) or 'metawikibeta' (beta).
getGlobalDatabase()
string
Returns 'wikidb' (production) or 'wikidbbeta' (beta). This is the cross-wiki database used for CentralAuth, CreateWiki, ManageWiki, GlobalBlocking, and other global tables.
getIncidentsDatabase()
string
Returns the realm-appropriate incidents database name (mapped from the private INCIDENTS_DATABASE constant).
isBeta()
bool
Returns true if $this->server ends with .betaoasis.xyz.
getSharedDomain()
string
Returns 'accounts.wikioasis.org' or 'accounts.betaoasis.xyz' — the CentralAuth shared login domain for the current realm.
setDatabase()
void
Sets $wgConf->settings['wgDBname'][$dbname] and the global $wgDBname. Also updates $wgVirtualDomainsMapping for the virtual-createwiki and virtual-managewiki virtual domains to point at the correct global database.
setServers()
void
Writes the full dbname => URL server map into $wgConf->settings['wgServer'] and sets the global $wgServer to the current wiki’s URL.
setSiteNames()
void
Writes the full dbname => sitename map into $wgConf->settings['wgSitename'] and sets the global $wgSitename to the current wiki’s site name.
getSettingValue(string $setting, string $wiki = 'default')
mixed
Returns the value of a per-wiki ManageWiki setting. Checks the CreateWiki cache array’s settings key first; falls back to $wgConf->get().
ParameterTypeDescription
$settingstringThe MediaWiki global variable name (e.g. 'wgMaxArticleSize')
$wikistringThe wiki DB name or 'default' for the fallback
isExtensionActive(string $extension)
bool
Returns true if the named extension is in the active extensions list for the current wiki.
isAnyOfExtensionsActive(string ...$extensions)
bool
Returns true if at least one of the provided extension names is active. Useful for conditional blocks that apply to multiple related extensions.
isAllOfExtensionsActive(string ...$extensions)
bool
Returns true only if every provided extension name is active. Useful for features that require multiple extensions simultaneously.
loadExtensions()
void
The main extension loader. Reads the per-wiki CreateWiki cache, resolves the extension-list cache for the active MediaWiki version (building it from glob() + ExtensionProcessor on a cache miss), calls handleDisabledExtensions(), then queues each active extension’s JSON manifest file via ExtensionRegistry::queue().

Usage Example

// Instantiated once in LocalSettings.php
$wi = new MirahezeFunctions();

// Check if an extension is active
if ( $wi->isExtensionActive( 'VisualEditor' ) ) {
    $wgVisualEditorAvailableNamespaces = [ NS_MAIN => true ];
}

// Resolve the current wiki's MediaWiki version
$version = MirahezeFunctions::getMediaWikiVersion( $wgDBname );

// Get per-wiki setting value from ManageWiki
$value = $wi->getSettingValue( 'wgMaxArticleSize' );

// Check realm
if ( $wi->isBeta() ) {
    $wgSomeFeatureEnabled = false;
}

// Require two extensions to be active simultaneously
if ( $wi->isAllOfExtensionsActive( 'Wikibase', 'WikibaseLexeme' ) ) {
    // lexeme-specific config
}
Because MirahezeFunctions is instantiated at the top of LocalSettings.php, $wi is available throughout the entire configuration file tree. All extension config files (e.g. Wikibase.php) rely on $wi->isExtensionActive() before applying settings.

Build docs developers (and LLMs) love