Page MenuHomePhabricator

Translatable pages filter for Special:WhatLinksHere doesn't work properly
Open, MediumPublic2 Estimated Story PointsBUG REPORT

Description

Problem

The "Hide translation pages" filter on Special:WhatLinksHere (added in T216368: Allow to hide translations on special page "WhatLinksHere") gives wrong results.
The filter was added to the outer query, which runs after the inner backlink query has already applied its LIMIT.
So pages that should be listed get dropped, and result counts change between views.
The integration was disabled (Gerrit 1120564) until a proper fix (T385139#10559646).

Reported symptoms:

This is a great feature improvement that I appreciate, but it seems to be hiding the base-page for translations too, even when they ought to still be shown. E.g.

  • Visit https://www.mediawiki.org/wiki/Special:WhatLinksHere/Template:Caution
  • Click "View … 500", and see there are "393 items" ✅ (optional step, not needed to reproduce the bug)
  • Click "Hide translation pages", click "Go", and see there are "30 items", and the page Manual:FAQ (and many others) is no longer visible. ❌
    • However, (bug clue?) if we then click "View … 500" there are suddenly "46 items" including the missing pages. That number shouldn't have changed. ❓

This is a significant problem, because when editors are trying to check for example pages that might be affected by a change, they will not see the complete list of affected locations.

Solution

  • Core: add SpecialWhatLinksHereBacklinkQuery hook that lets extensions modify the inner backlink query (and the redirect query) before LIMIT is applied.
  • Translate: re-add the filter via the new hook

Acceptance criteria

  • With "Hide translation pages" enabled, every non-translation page that links to the target is listed (no source/translatable pages missing).
  • Translation pages (translate-is-translation page prop) are never listed when the filter is enabled.
  • Pagination is correct: limit returns exactly N non-translation results when ≥N exist, and "next" pages neither skip nor repeat entries.
  • Works for page links, template transclusions, file links and redirects, alone and combined with the namespace selector (incl. "invert").
  • Without the filter, output is identical to current behaviour.
  • Inner-query performance verified with EXPLAIN on large targets (e.g. mediawiki.org Template:Caution, Meta-Wiki) and acked by DBA if needed.
  • Translate does not fatal on MediaWiki versions without the new hook (bump requires to 1.48 or guard).
  • PHPUnit coverage for filtering-before-pagination (exists for pagelinks); add templatelinks/redirect + namespace cases.

Out of scope

  • Documenting the option on Help:What links here – separate task (follow-up to Quiddity's request).

QA steps

Test 1:
On production:

  1. Visit https://www.mediawiki.org/wiki/Special:WhatLinksHere/Template:Caution
  2. Compare the list with and without "Hide translation pages": filtered list = unfiltered list minus /xx translation subpages.
  3. Set limit=20, page through with "next 20"; no duplicates or gaps.
  4. Repeat with a namespace selected, and with transclusion-only and redirect-only targets.

Test 2:
another example from.https://phabricator.wikimedia.org/T385139#10559091

  • Navigate to https://www.mediawiki.org/wiki/Special:WhatLinksHere/Template:GithubDownload
  • Select 'Hide translation pages' & click 'Go'
    • 17 pages are displayed -- but none in the Extension: namespace.
  • Select 'Extension' from the 'Namespace' dropdown (replacing the default 'all' selection) & click 'Go' (leaving the 'Hide translation pages' option selected)
    • Pages in the Extension: namespace that link to the template in question are now listed.

Event Timeline

Looking at this, there are four translatable pages:

  • Wikidata:List of oversighters
  • Wikidata:Administrators
  • Wikidata:Oversight
  • Wikidata:Administrators/Timeline

But only Wikidata:List of oversighters is not visible when translations are filtered out.

I was looking at the values present in the page_props table to see what props the page has:

SELECT * FROM page_props WHERE pp_page=16586252;
+----------+-----------------------------+-----------+------------+
| pp_page  | pp_propname                 | pp_value  | pp_sortkey |
+----------+-----------------------------+-----------+------------+
| 16586252 | translate-has-languages-tag |           |       NULL |
| 16586252 | wikibase_item               | Q18011286 |       NULL |
+----------+-----------------------------+-----------+------------+
2 rows in set (0.001 sec)

Which looks OK.

Another example of an issue with the translation pages filter that I just noticed, in case it's helpful:

  • Navigate to https://www.mediawiki.org/wiki/Special:WhatLinksHere/Template:GithubDownload
  • Select 'Hide translation pages' & click 'Go'
    • 17 pages are displayed -- but none in the Extension: namespace.
  • Select 'Extension' from the 'Namespace' dropdown (replacing the default 'all' selection) & click 'Go' (leaving the 'Hide translation pages' option selected)
    • Pages in the Extension: namespace that link to the template in question are now listed.

The WhatLinksHere query is weird:

SELECT page_id,page_namespace,page_title,rd_from,rd_fragment,page_is_redirect FROM ***SUBQUERY*** `temp_backlink_range` JOIN `page` ON ((tl_from = page_id)) LEFT JOIN `page_props` `translate_pp` ON ((translate_pp.pp_page=page_id) AND translate_pp.pp_propname = 'translate-is-translation') WHERE translate_pp.pp_value IS NULL ORDER BY page_namespace ASC,page_id ASC LIMIT 51

SUBQUERY: (SELECT tl_from,rd_from,rd_fragment FROM `templatelinks` LEFT JOIN `redirect` ON ((rd_from = tl_from) AND rd_title = 'Main_Page' AND rd_namespace = 0 AND rd_interwiki = '') WHERE tl_target_id = 34 AND tl_from_namespace IN (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,90,91,92,93,100,101,106,107,420,421,828,829,1102,1103,1198,1199,1704,1705) ORDER BY tl_from_namespace ASC,tl_from ASC LIMIT 102 )

My guess is that we are filtering on the outer query, why we should be doing that in the inner query.

Given that the fix doesn't seem simple, and that our team is currently busy with other things with deadlines, I'm proposing that we temporarily disable this feature to avoid displaying wrong results to the users and wasting their time investigating the odd results.

Change #1120564 had a related patch set uploaded (by Nikerabbit; author: Nikerabbit):

[mediawiki/extensions/Translate@master] Disable Special:WhatLinksHere integration

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

Given that the fix doesn't seem simple, and that our team is currently busy with other things with deadlines, I'm proposing that we temporarily disable this feature to avoid displaying wrong results to the users and wasting their time investigating the odd results.

No objections to this from where I’m sitting. Do you think it’s worth a User-notice in case editors wonder why the 'hide translation pages' checkbox no longer appears at Special:WhatLinksHere?

I'm not sure if it is needed, but I don't oppose if someone thinks it's useful.

Change #1120564 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Disable Special:WhatLinksHere integration

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

Change #1346488 had a related patch set uploaded (by Nikerabbit; author: Nikerabbit):

[mediawiki/core@master] Add SpecialWhatLinksHereBacklinkQueryHook

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

Change #1346498 had a related patch set uploaded (by Nikerabbit; author: Nikerabbit):

[mediawiki/extensions/Translate@master] Re-add Special:WhatLinksHere filtering with new core hook

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

hueitan set the point value for this task to 2.Thu, Oct 15, 9:03 AM
hueitan updated the task description. (Show Details)

Change #1346488 merged by jenkins-bot:

[mediawiki/core@master] Add SpecialWhatLinksHereBacklinkQueryHook

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

Change #1361393 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/core@master] Hard-deprecate SpecialWhatLinksHereQuery hook

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

Change #1346498 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Re-add Special:WhatLinksHere filtering with new core hook

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

Change #1361393 merged by jenkins-bot:

[mediawiki/core@master] Hard-deprecate SpecialWhatLinksHereQuery hook

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