Page MenuHomePhabricator

Provide easy access to next/previous revisions in revisions response
Closed, DeclinedPublic

Description

Using the following parameters

var params = {
  prop: 'revisions',
  revids: revId,
  rvprop: 'ids|timestamp|comment|size|flags|sizediff|user',
  rvdiffto: 'prev'
};

I can obtain a diff of the revision revId compared with the previous revision. I can get the revision id of the previous revision via this query but there is no way to know what the next query is.

I would like to also have the next revId so I can render a link to the next diff in the series without having to perform a second HTTP request as I do not need the next diff.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 23 2016, 7:28 PM
Anomie added a subscriber: Anomie.Aug 23 2016, 8:10 PM

Fetching the previous and next revision ids would take two database queries per input revision id.

SELECT rev_id FROM revision WHERE rev_page = $1 AND rev_id < $2 ORDER BY rev_id DESC;
SELECT rev_id FROM revision WHERE rev_page = $1 AND rev_id > $2 ORDER BY rev_id ASC;

Since there can be up to 500 revision ids input directly, or 5000 with a generator, that would be a lot of individual database queries. I can't think of any sensible way to batch them. If we only do it for diffs that are actually returned, we might be able to get away with the extra query in that special situation.

However, if you're just chaining diffs, you don't actually need to know the next revision ID. You already know that the "previous" link is revids=$fromid&rvdiffto=prev; for "next" you can do revids=$toid&rvdiffto=next if the only thing you need is the diff HTML without any of the rvprop data. For example, revids=12345678&rvdiffto=prev tells you from=8943129 and to=12345678. The previous diff is revids=8943129&rvdiffto=prev, while the next diff is revids=12345678&rvdiffto=next.

Anomie closed this task as Declined.May 25 2017, 2:49 PM

Since this seems to only be useful in the context of diffs, and retrieving diffs from prop=revisions is now deprecated (T164106: Deprecate parsing and diff options in ApiQueryRevisionsBase), I'm going to decline this.

https://gerrit.wikimedia.org/r/#/c/352191/ will add previous and next revision information to the output of action=compare.

Sounds like a plan. let me know when that's done and I'll personally test out the new API and let you know if anything is missing!

The patch is done already, it's just waiting for code review and merge.

Aklapper removed a subscriber: Anomie.Oct 16 2020, 5:28 PM