Page MenuHomePhabricator

Expose wiki ID in Lua Site library
Closed, ResolvedPublic

Description

Expose wiki ID in mw.site library in Scribunto (instead of $wgDBname which is unsuitable when multiple wikis are stored on the same database; see discussion below and on the linked patch).

Original request:
Create component for $wgDBname in mw.site.

Rationale:
When providing Lua modules for multiple wiki projects, local adaptions should be supported easily. Based on a short DB name the appropriate adjustments need to be accessed.

Currently there is available only a mw.site.server field.

This requires

if mw.site.server == "//de.wikipedia.org"  or
    mw.site.server == "//de.wikipedia.beta.wmflabs.org" then
    site = "dewiki"
end

Details

Related Changes in Gerrit:

Event Timeline

Anomie subscribed.

Local adaptations would probably be better done with a configuration data-module rather than code branching on the identity of the current site.

IMO it would be more sensible to provide mw.site.wikiid as wfWikiId(), rather than $wgDBname.

I tend to agree with Anomie on this. I'm not sure this should be done.

Some wikiid or wikiId rather than traditional dbname would be fine with me.

The concept of local config modules is understood, as you might see here or here or here.

However, local configs require local people and even sysops to maintain a software configuration theirselves. I know many wiks that are not able to do this with local software experts, asking e.g. German Wikipedia for support. They would have to adapt each new feature locally.

A config scenario might be shared on a larger number of wikis, with exceptions for only a few ones, like e.g. Commons. Then global maintenance of a few standard groups of different profiles provides a more robust behaviour and will share all updates, and adaptions are performed by some global experts. Might be combined and overruled by local config modules anyway.

The concept of local config modules is understood, as you might see here or here or here.

However, local configs require local people and even sysops to maintain a software configuration theirselves. I know many wiks that are not able to do this with local software experts, asking e.g. German Wikipedia for support. They would have to adapt each new feature locally.

A config scenario might be shared on a larger number of wikis, with exceptions for only a few ones, like e.g. Commons. Then global maintenance of a few standard groups of different profiles provides a more robust behaviour and will share all updates, and adaptions are performed by some global experts. Might be combined and overruled by local config modules anyway.

This seems like a non sequitur. None of this is improved by being able to automatically switch by wiki ID, since the different configurations for different wiki IDs would have to be written anyway (just in a different place). And centralized modules are also totally orthogonal to this.

Change #1241054 had a related patch set uploaded (by R4356thwiki; author: R4356thwiki):

[mediawiki/extensions/Scribunto@master] Add mw.site.dbName

https://gerrit.wikimedia.org/r/1241054

This would probably be worth announcing via Tech News.

Redmin renamed this task from Expose DBNAME in Lua Site library to Expose wiki ID in Lua Site library.Mar 9 2026, 4:32 PM
Redmin updated the task description. (Show Details)
Redmin updated the task description. (Show Details)

Change #1241054 merged by jenkins-bot:

[mediawiki/extensions/Scribunto@master] Add mw.site.wikiId

https://gerrit.wikimedia.org/r/1241054

@Redmin how should this be worded for Tech News?

The [[mw:Extension:Scribunto|Scribunto]] extension provides different pieces of information about the wiki where the module is being used via the [[mw:Extension:Scribunto/Lua reference manual#mw.site|mw.site]] library. Starting lasting week, the library also provides a [[mw:Extension:Scribunto/Lua reference manual#mw.site.wikiId|way]] of accessing the [[mw:Manual:Wiki ID|wiki ID]] that can be used to facilitate cross-wiki module maintenance.

Perhaps something like this will do. The change rode this week’s train.