WordPress.org

Make WordPress Core

Opened 9 months ago

Last modified 9 months ago

#40510 new enhancement

REST API: Post Revisions: Adding support for pagination

Reported by: benoitperson Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: needs-patch
Focuses: rest-api Cc:

Description

The post revisions REST endpoint currently has no support for pagination. While it works well for most usages with fairly low counts of revisions (Wordpress.com limits the number at 25 for instance), on posts with a revision count in the hundreds (or even thousands), this can quickly yield unreasonably large (Mb+ of pure text) and long (several seconds on my "test" instances) responses.

The API already supports pagination for a vast majority of ressources (posts, pages, categories, tags, users) and is normalised around using 2 integer parameters: page (default: 1)and per_page (default: 10).

I wonder if there is any reason why pagination was never implemented on that endpoint? Is it something potentially worth working on? Considering some of the past issues around high memory usage for the revisions page of wp-admin [0][1], it seems like getting a way to only load (for instance) the most recent revisions would be an interesting win to provide a smoother experience with revisions.

[0] https://core.trac.wordpress.org/ticket/34560
[1] https://core.trac.wordpress.org/ticket/24958

PS: To provide some (more) context, there is an ongoing effort to support revisions in Calypso: https://github.com/Automattic/wp-calypso/pull/12733 from which this enhancement request emerged.

Change History (2)

#1 @danielbachhuber
9 months ago

I wonder if there is any reason why pagination was never implemented on that endpoint?

Probably an oversight, to be honest.

Is it something potentially worth working on?

Go for it!

#2 @rmccue
9 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Seems to just be something that was missed. Let's add it. :)

Note: See TracTickets for help on using tickets.