Page MenuHomePhabricator

Allow retrieval of specific revision content in Page Source/Html Handlers
Closed, ResolvedPublic

Description

I might be missing something, but from what I see in includes/Rest/Handler/PageContentHelper.php and https://api.wikimedia.org/wiki/API_reference/Core/Pages/Get_page it does not seem easily possible to retrieve HTML or wikitext for a specific revision ID in the page HTML/source REST handlers. I propose adding an optional revision query parameter to PageContentHelper so that one could query for e.g. https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth?revision=1025714312.

My specific motivation for this is that in the link recommendation service, I would like to make it to retrieve link recommendations for older content. This is useful when debugging how users interacted with the link suggestion tool in MediaWiki. As it is now, a user accepts some link suggestions and makes a new revision to the article Earth. If I want to understand which suggestion were shown to the user, I need to be able to call the link recommendation service using a specific revision ID for the article Earth. That's possible using a POST request (https://api.wikimedia.org/wiki/API_reference/Service/Link_recommendation/Get_link_recommendations_for_revision) that supplies the revision ID and raw wikitext, but that is not as straightforward as a GET request (https://api.wikimedia.org/wiki/API_reference/Service/Link_recommendation/Get_link_recommendations) which says which revision ID should be used by the link recommendation service.

Event Timeline

The handlers for these already exist in core, e.g. RevisionHtmlHandler. But, they're exposed under beta cluster only, see https://en.wikipedia.beta.wmflabs.org/w/rest.php/coredev/v0/revision/1/html because of the 'corded/v0' prefix.

The reason for being under /v0 is that there is this horrific dependency from core to Parsoid extension until T265518 is resolved. All that needs to be done in core is to move the route definitions from coreDevelopmentRoutes.json into coreRoutes.json. But I would really love it if we poked parsing team about moving making parsoid a library before we expose even more Parsoid-dependent API. But if that's not possible, just moving the routes is ok too.

BPirkle triaged this task as Medium priority.Jun 1 2021, 9:03 PM
BPirkle moved this task from Inbox to Feature Requests to Review on the Platform Engineering board.
BPirkle subscribed.

From T265518: Move Parsoid ServiceWorker.php and extension/src/Config into core, regarding the parsoid changes:

We'll do this early in 1.37 so we're not in this same position again.

So hopefully we'll be in a position to move the routes cleanly before long. @kostajh , is there a specific time frame regarding the links recommendation project that we should be aware of?

Moving this into "Feature Requests to Review" with Medium priority for now. Let us know if there's an urgent reason that this shouldn't wait for the parsoid changes.

The handlers for these already exist in core, e.g. RevisionHtmlHandler. But, they're exposed under beta cluster only, see https://en.wikipedia.beta.wmflabs.org/w/rest.php/coredev/v0/revision/1/html because of the 'corded/v0' prefix.

The reason for being under /v0 is that there is this horrific dependency from core to Parsoid extension until T265518 is resolved. All that needs to be done in core is to move the route definitions from coreDevelopmentRoutes.json into coreRoutes.json. But I would really love it if we poked parsing team about moving making parsoid a library before we expose even more Parsoid-dependent API. But if that's not possible, just moving the routes is ok too.

I see, thanks for the info on that.

From T265518: Move Parsoid ServiceWorker.php and extension/src/Config into core, regarding the parsoid changes:

We'll do this early in 1.37 so we're not in this same position again.

So hopefully we'll be in a position to move the routes cleanly before long. @kostajh , is there a specific time frame regarding the links recommendation project that we should be aware of?

Moving this into "Feature Requests to Review" with Medium priority for now. Let us know if there's an urgent reason that this shouldn't wait for the parsoid changes.

No rush from our end. It can wait for the Parsoid changes. Thanks!

The handlers for these already exist in core, e.g. RevisionHtmlHandler. But, they're exposed under beta cluster only, see https://en.wikipedia.beta.wmflabs.org/w/rest.php/coredev/v0/revision/1/html because of the 'corded/v0' prefix.

The reason for being under /v0 is that there is this horrific dependency from core to Parsoid extension until T265518 is resolved. All that needs to be done in core is to move the route definitions from coreDevelopmentRoutes.json into coreRoutes.json. But I would really love it if we poked parsing team about moving making parsoid a library before we expose even more Parsoid-dependent API. But if that's not possible, just moving the routes is ok too.

I see, thanks for the info on that.

From T265518: Move Parsoid ServiceWorker.php and extension/src/Config into core, regarding the parsoid changes:

We'll do this early in 1.37 so we're not in this same position again.

So hopefully we'll be in a position to move the routes cleanly before long. @kostajh , is there a specific time frame regarding the links recommendation project that we should be aware of?

Moving this into "Feature Requests to Review" with Medium priority for now. Let us know if there's an urgent reason that this shouldn't wait for the parsoid changes.

No rush from our end. It can wait for the Parsoid changes. Thanks!

@BPirkle just checking in on this task, is there an update on timeline?

Does RevisionSourceHandler / /coredev/v0/revision/{id} also depend on Parsoid? The functionality seems unrelated.

Change 752628 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/core@master] rest.php: Expose /v1/revision/{id}

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

Does RevisionSourceHandler / /coredev/v0/revision/{id} also depend on Parsoid? The functionality seems unrelated.

I think the comment about Parsoid may have been specifically for RevisionHtmlHandler.

Change 752630 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/core@master] rest: Allow getting page source by revision ID

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

Change 752630 abandoned by Kosta Harlan:

[mediawiki/core@master] rest: Allow getting page source by revision ID

Reason:

Too many other things going on, and we have an alternate implementation in research/mwaddlink repo to get what we need for this

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

Change 752628 abandoned by Kosta Harlan:

[mediawiki/core@master] rest.php: Expose /v1/revision/{id}

Reason:

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

@kostajh is this still relevant or can this ticket be closed out?

FJoseph-WMF lowered the priority of this task from Medium to Low.Mar 19 2024, 6:24 PM

@kostajh is this still relevant or can this ticket be closed out?

The work wasn't done, so I think it would make sense to leave it open, even if the team doesn't intend to work on it in.

IMO it's still a useful feature, but it's not something I or (as far as I know) anyone else is waiting on.

daniel claimed this task.