Page MenuHomePhabricator

Some interwiki links that point back to the source wiki are broken
Open, Needs TriagePublic

Description

Since T198584: Update wikilinks to point back to source project, FileImporter updates wiki links in the file description. This is critical because, for example, [[:de:…]] on Wikisource means something different than on Wikipedia. Other examples:

In the code, this is implemented in the WikiLinkPrefixer class.

Here is the issue: Some interwiki prefixes are marked as "local" (see Title::wasLocalInterwiki()), but others are not. Links with "local" interwiki prefixes redirect, non-local ones don't. That's why the phab: link above works just fine, but the doi: one doesn't.

Reported here: https://www.mediawiki.org/wiki/Topic:Vrewan6izwrmbhgs

Ideas:

  • One possible solution is to compare the interwiki tables from the source and target wiki, and skip any extra prefixing if both interwiki prefixes resolve to the same target URL. Accessing the target wiki's interwiki table is easy. To get the source wiki's interwiki table, we would need to do just another API request.
  • Another idea is to act different depending on the "local" flag. When a link in the wikitext starts with a prefix that is not local, we don't add more prefixes. However, this might have issues: As of now, we don't care about existing prefixes (that's kind of the whole point of what WikiLinkPrefixer does). And this might not only leave broken links in the wikitext, but also links that point to something different than before.
  • Both ideas can be modified by just using the Commons interwiki table, and assuming it is "close enough" to the one on the source wiki. Maybe it's fine to live with (presumably extremely rare) mismatches in the interwiki tables, when we can fix most, if not all non-local interwiki links.