Page MenuHomePhabricator

Support remote Media in Attribution REST endpoint
Open, MediumPublic5 Estimated Story Points

Description

MediaWiki provides a way to fetch media from remote instances, which allows Wikipedias to use Media from Commons as if they were available in the wiki.

For example: https://commons.wikimedia.org/wiki/File:Into_Cwm_Du_-_geograph.org.uk_-_681141.jpg - is a File uploaded to commons, and do not exist on other wikis as local file. But thanks to wgForeignFileRepos configuration any wiki can list this file.

This makes this file available on wikis:
EN - http://en.wikipedia.org/wiki/File:Into_Cwm_Du_-_geograph.org.uk_-_681141.jpg
PL - https://pl.wikipedia.org/wiki/Plik:Into_Cwm_Du_-_geograph.org.uk_-_681141.jpg
DE - https://de.wikipedia.org/wiki/Datei:Into_Cwm_Du_-_geograph.org.uk_-_681141.jpg

There is a note on the page, that file comes from Commons, but sending an HTTP request to those URLs return Media page.

Now, the AttributionAPI doesn't support ForeignFileRepos, therefore Attribution for this file is only available in the source project:

Why this matters

The file information is returned in multiple ways, different extensions handle it differently. For example PageImages when queried for Bird ( https://en.wikipedia.org/w/api.php?action=query&generator=images&titles=Bird&prop=info) returns:

{
    "batchcomplete": "",
    "continue": {
        "gimcontinue": "3410|Bar-tailed_Godwit_migration.jpg",
        "continue": "gimcontinue||"
    },
    "query": {
        "pages": {
            "-1": {
                "ns": 6,
                "title": "File:17.6-24-1974-Cuerda-seca-flisepanel.jpg",
                "missing": "",
                "known": "",
                "contentmodel": "wikitext",
                "pagelanguage": "en",
                "pagelanguagehtmlcode": "en",
                "pagelanguagedir": "ltr"
            },

As you see it only lists Media as File:17.6-24-1974-Cuerda-seca-flisepanel.jpg. But it doesn't state if this file lives in commons or on local wiki.

If automated script decides to fetch the attribution for image, most likely it's going to use same domain and send request to https://en.wikipedia.org/w/rest.php/attribution/v0-beta/pages/File:17.6-24-1974-Cuerda-seca-flisepanel.jpg/signals. But this will end up with 404 not found, because this file do not exist on English Wikipedia.
To fetch file attribution script has to query Commons Attribution endpoint instead: https://commons.wikimedia.org/w/rest.php/attribution/v0-beta/pages/File:17.6-24-1974-Cuerda-seca-flisepanel.jpg/signals

Developer notes

File resolution in REST Handlers is processed in PageContentHelper and from initial check - looks like this code requires the Title to exist in current database.

Event Timeline

pmiazga renamed this task from Support remote Media in REST Endpoints to Support remote Media in Attribution REST endpoint.
Atieno triaged this task as Medium priority.Mar 24 2026, 5:25 PM
Atieno moved this task from Incoming (Needs Triage) to Backlog on the MW-Interfaces-Team board.
HCoplin-WMF set the point value for this task to 5.Thu, Apr 23, 3:24 PM

Notes from estimation:

  • Recommendation: Return the correct information in the response. For example, if a Wikipedia image is requested but it actually lives on Commons, return the Commons information for accuracy and completeness.