Page MenuHomePhabricator

Reader gets language links
Closed, ResolvedPublic3 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"?

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)
eprodromou updated the task description. (Show Details)

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.

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?

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.

Aklapper added a subscriber: eprodromou.

Adding missing MediaWiki-REST-API code project tag as Core Platform Team Initiatives (MW REST API in PHP) team tag is archived and its parent Platform Engineering team does not exist anymore

Subtask has been closed for years, resolving