Page MenuHomePhabricator

Reader gets language links
Open, MediumPublic3 Estimated Story Points

Description

"As a Reader, I want to get a list of alternate language versions of a page, so that I can switch to another language version."

GET /page/{title}/links/language

Returns language links for the page.

Notable request headers: none

Request body:
None

Status:
200 - OK, content is the language links
404 – page does not exist

Headers:

Body: JSON
array of pages in order by language code. Each page result includes:
code: language code
name: language name in target language
title: display title of the page ("Talk:Main Page")
key: prefixed db key for the page ("Talk:Main_Page")

Event Timeline

410 – page was deleted

410 Gone client error response code indicates that access to the target resource is no longer available at the origin server and that this condition is likely to be permanent. - pages are not deleted permanently in MW, why are we using 410?

307 – page is redirect; Location: header gives location of redirect page

Under what conditions are we redirecting?

name: language name

Language name in which language? In the language of the wiki the request is made to? In the target language of the langlink? In English?

location of the API entry for the page

What is an "API entry"?

CCicalese_WMF triaged this task as Medium priority.Oct 23 2019, 7:33 PM
tstarling added a subscriber: tstarling.EditedOct 25 2019, 1:08 AM

410 – page was deleted

410 Gone client error response code indicates that access to the target resource is no longer available at the origin server and that this condition is likely to be permanent. - pages are not deleted permanently in MW, why are we using 410?

I agree, RFC 7231 makes the point several times that the difference between 404 and 410 is permanence, not prior existence.

307 – page is redirect; Location: header gives location of redirect page

Under what conditions are we redirecting?

Presumably this means if the page has "#redirect" in the source. At T229663#5536853 I gave some considerations for delivering these kinds of user-specified redirects with a 302 status code. Evan removed the redirect requirement for that endpoint, but it is more feasible here.

Another class of redirects is those where the path contains a non-canonical title form and we want to redirect to the canonical form. These should presumably be delivered with a 301 status code, and the same for all other endpoints.

name: language name

Language name in which language? In the language of the wiki the request is made to? In the target language of the langlink? In English?

My guess is that it is the "autonym", i.e. the name of the language in itself, which is the usual language name used in language links in the UI.

location of the API entry for the page

What is an "API entry"?

Could be /page/{title}?

Responding now to the task description:

Last-Modified -- last time this page was modified

I assume this means the time the API response was last modified, per the definition in RFC 7232. We can probably use the page_links_updated field in the database for this. Wikibase adds language links by hooking ContentAlterParserOutput, which I assume is only called from contexts where page_links_updated will be updated.

ETag -- Etag

There's no obvious way to do ETags aside from putting the Last-Modified date inside a weak ETag. It may be premature optimisation to include this.

eprodromou updated the task description. (Show Details)Oct 25 2019, 5:45 PM
eprodromou updated the task description. (Show Details)
eprodromou updated the task description. (Show Details)
eprodromou updated the task description. (Show Details)Oct 25 2019, 5:50 PM

I took out the 410 and 307 responses.

I removed the caching headers.

I removed the URL for the remote page; we can add it back in when we get the page-reading user stories done.

I noted that it should be the language name in the target language, as we do for all (?) inter-wiki links.

WDoranWMF set the point value for this task to 3.Oct 30 2019, 10:19 PM

Change 548860 had a related patch set uploaded (by Ppchelko; owner: Ppchelko):
[mediawiki/core@master] REST: Introduce language links endpoint.

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

Just an idea, should we call it /v1/page/{title}/links/language? Seems nicer and we can add more subtypes of links later?

Which standard are we using for language codes? Is there a link to the list of available codes?

Perfect, thanks!

eprodromou updated the task description. (Show Details)Nov 6 2019, 6:41 PM

Just an idea, should we call it /v1/page/{title}/links/language? Seems nicer and we can add more subtypes of links later?

Sure. I updated the user story.

Change 548860 merged by jenkins-bot:
[mediawiki/core@master] REST: Introduce language links endpoint.

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

Waiting for the tests in the sub-task to get reviewed.