Page MenuHomePhabricator

Provide a reliable way to get a wiki ID from an interwiki prefix
Open, Needs TriagePublic

Description

As noted in T306712, sometimes you may need to get a wiki ID from an interwiki prefix. This currently does not seem possible. The only solution I could find is to use

MediaWikiServices::getInterwikiLookup()->fetch( "interwiki-prefix" )->getWikiID();

However, this does not work reliably because the iw_wikiid field is not guaranteed to be present, even for wikis on the same wikifarm. This is not just a theoretical possibility: AFAICS, iw_wikiid is empty for interwikis in production (at least some that I tested), and is also absent in some interwikis that I created on my local via Special:Interwiki (which doesn't support setting that field at all).

There should be a way to do this, and if Interwiki::getWikiID() is known to be unreliable, it should be documented as such.

T224020 could be somewhat related.