Page MenuHomePhabricator

Title::getLinksTo() appears to be broken
Closed, ResolvedPublicBUG REPORT

Description

It's hard to imagine, but it seems like change 3b6345ca1611, from June 2021, broke the method Title::getLinksTo(), and by extension the method Title::getTemplateLinksTo(), which calls getLinksTo(). Title::getLinksTo() formerly called self::getSelectFields() in order to set the SELECT fields for the DB query that it runs; this change replaced that call with LinkCache::getSelectFields(). Title::getSelectFields() returns the strings "page_namespace" and "page_title" within its array, while LinkCache::getSelectFields() does not. And Title::getLinksTo() makes use of "page_namespace" and "page_title" when processing the query results, so those missing fields are a problem.

Looking through the code, it looks like this method is barely called (which is probably why no one noticed the problem), with one exception: when "action=info" (i.e. the InfoAction class) is used on a template page, and when $wgMiserMode is set to false. I can't reproduce the problem on any Wikimedia sites (maybe $wgMiserMode is always turned on for them?), but I could reproduce it on this wiki, which runs MW 1.37, for example:

https://en.altlinux.org/Template:ISO?action=info

Event Timeline

Correction: it looks like the patch wasn't merged in until September, which makes this bug more plausible.

Change 770939 had a related patch set uploaded (by Chris Rishel; author: Chris Rishel):

[mediawiki/core@master] Title: Fix broken query in getLinksTo()

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

This comment was removed by Chrishel.

Change 770939 abandoned by Chris Rishel:

[mediawiki/core@master] Title: Fix broken query in getLinksTo()

Reason:

Should've been submitted to the 1.37 branch

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

Change 770941 had a related patch set uploaded (by Chris Rishel; author: Chris Rishel):

[mediawiki/core@REL1_37] Title: Fix broken query in getLinksTo()

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

This bug appears to have been fixed in 1.38 but still exists in MW 1.37.1. I've submitted a patch for the 1_37 branch here: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/770941

Change 811282 had a related patch set uploaded (by Zabe; author: Amir Sarabadani):

[mediawiki/core@REL1_37] cache: Add four fields to LinkCache::getSelectFields

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

Change 811282 merged by jenkins-bot:

[mediawiki/core@REL1_37] cache: Add four fields to LinkCache::getSelectFields

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

I confirm the patch merged on July 6 fixes the issue, to this task can be closed.

Zabe claimed this task.

Change 770941 abandoned by Zabe:

[mediawiki/core@REL1_37] Title: Fix broken query in getLinksTo()

Reason:

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/811282/ fixed the issue

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