Page MenuHomePhabricator

Implement support for FlaggedRevs in citation count for Attribution API
Closed, ResolvedPublic5 Estimated Story Points

Description

Following the work on T418499: Attribution API MVP: Provide initial-pass base reference count we've implemented a basic count for references in articles requested through the Attribution API based on their HTML. This works well for all pages that have Parser Cache, and use that cache to examine the HTML and output a close-to-accurate citation count with minimal RegEx.

However, as shown in T420024: [SPIKE] Attribution API Citation count followup: Citation # in Flagged Revs wikis, this will not work for pages that are utilizing FlaggedRevs 'stable' functionality. Those pages use the FlaggedRevs cache and not the regular Parser Cache, and in order to get the HTML from those pages we need to request it from the correct patch. This is relevant to several wikis (German and Russian Wikipedias) but also potentially to groups of pages on other wikis (like some pages on English Wikipedia).

This ticket is a followup to the investigation, utilizing the solution offered by Aaron to implement a proper check (whether the page utilizes 'stable' state from FlaggedRevs) and extract the correct HTML.

Acceptance criteria

  • Add a check to the "number of citations" operation that checks whether there's a need to fall back on FlaggedRevs cache
  • Implement the fallback to read from the correct cache (Parser vs FlaggedRevs)
  • Implement a "no response found" fallback in case we have a cache-miss from FlaggedRevs (which does not automatically triggers a parse)
  • Make sure the regex is correctly implemented for both cases
  • Add unit tests to verify both types of HTML can work

Event Timeline

HCoplin-WMF triaged this task as High priority.
HCoplin-WMF set the point value for this task to 5.

Change #1265557 had a related patch set uploaded (by Aghirelli; author: Aghirelli):

[mediawiki/extensions/WikimediaCustomizations@master] Attribution: Read citation count from FlaggedRevs stable cache

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

Change #1265557 had a related patch set uploaded (by Aghirelli; author: Aghirelli):

[mediawiki/extensions/WikimediaCustomizations@master] Attribution: Read citation count from FlaggedRevs stable cache

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

Change #1270062 had a related patch set uploaded (by Aghirelli; author: Aghirelli):

[integration/config@master] phan: Add FlaggedRevs dependency for WikimediaCustomizations

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

Change #1270062 merged by jenkins-bot:

[integration/config@master] Zuul: [mediawiki/extensions/WikimediaCustomizations] Add FlaggedRevs dep

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

Mentioned in SAL (#wikimedia-releng) [2026-04-13T14:42:16Z] <James_F> Zuul: [mediawiki/extensions/WikimediaCustomizations] Add FlaggedRevs dep, for T421011

Change #1265557 merged by jenkins-bot:

[mediawiki/extensions/WikimediaCustomizations@master] Attribution: Read citation count from FlaggedRevs stable cache

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