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:
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:
- Visit https://www.mediawiki.org/wiki/Special:WhatLinksHere/Template:Caution
- Compare the list with and without "Hide translation pages": filtered list = unfiltered list minus /xx translation subpages.
- Set limit=20, page through with "next 20"; no duplicates or gaps.
- 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.