Page MenuHomePhabricator

action=query&prop=pageterms API doesn't implement language fallback logic
Open, MediumPublic

Description

action=query&prop=pageterms API doesn't implement language fallback logic.

For example, https://www.wikidata.org/wiki/Q1075624 (Wikia Search) currently has a description in English en, but not in British English en-gb. I would expect the following two API queries to give the same result:

https://en.wikipedia.org/w/api.php?action=query&format=jsonfm&prop=pageterms&titles=Wikia+Search&uselang=en
https://en.wikipedia.org/w/api.php?action=query&format=jsonfm&prop=pageterms&titles=Wikia+Search&uselang=en-gb

However, the second returns no description.

This affects mw.widgets.TitleWidget, as used in VisualEditor.

Event Timeline

Jdforrester-WMF raised the priority of this task from to Medium.
Jdforrester-WMF updated the task description. (Show Details)

Ok, maybe I just don't get it, but what do you mean exactly, how can I reproduce it? :]

Sounds like it should be Wikibase's responsibility. TitleWidget doesn't
ask for a specific language, as far as I can see.

Ok, maybe I just don't get it, but what do you mean exactly, how can I reproduce it? :]

Load VE on a WMF production wiki with your userlang set to en-gb and search for something that has a description in en but not en-gb (in quick testing, Wikia is in this sate right now). You'll get no description. Change interface language to en and you'll get it.

Sounds like it should be Wikibase's responsibility. TitleWidget doesn't
ask for a specific language, as far as I can see.

OK, re-titling slightly.

Jdforrester-WMF renamed this task from mw.widgets.TitleWidget doesn't do language fallback for Wikidata descriptions to mw.widgets.TitleWidget doesn't get language fallback for Wikidata descriptions.Feb 4 2016, 11:28 PM
Jdforrester-WMF set Security to None.
matmarex renamed this task from mw.widgets.TitleWidget doesn't get language fallback for Wikidata descriptions to action=query&prop=pageterms API doesn't implement language fallback logic.Feb 5 2016, 2:06 AM
matmarex updated the task description. (Show Details)
Michael updated the task description. (Show Details)

What makes this non-trivial to fix is that the current API response is:

{
    "batchcomplete": "",
    "query": {
        "pages": {
            "10346388": {
                "pageid": 10346388,
                "ns": 0,
                "title": "Wikia Search",
                "terms": {
                    "label": [
                        "Wikia Search"
                    ],
                    "description": [
                        "defunct free and open-source web search engine by Wikia"
                    ]
                }
            }
        }
    }
}

If we want to add language fallback, then we have to somehow indicate the language that we're returning. And we may have to do that on a per-term basis, as the label might have a match in the requested language, but the description might not and thus is falling back.
All that is doable, but not quick.