Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework: Improve how post revisions are handled #3258

Closed
gziolo opened this issue Oct 31, 2017 · 5 comments
Closed

Framework: Improve how post revisions are handled #3258

gziolo opened this issue Oct 31, 2017 · 5 comments
Assignees
Labels
Core REST API Task Task for Core REST API efforts Framework Issues related to broader framework topics, especially as it relates to javascript [Priority] High Used to indicate top priority items that need quick attention [Type] Enhancement A suggestion for improvement.

Comments

@gziolo
Copy link
Member

gziolo commented Oct 31, 2017

Issue Overview

When fixing #3167 with #3233 we opened a discussion on how to handle post revisions in the long run:

While it doesn't appear that it will prevent content filtering from being run, an alternative solution to limiting the size of the version history payload in the upcoming 4.9 release is to specify only the necessary fields on the API request:
e.g. /wp/v2/posts/4462/revisions?_fields=id

See: https://core.trac.wordpress.org/ticket/38131

@aduth: Yes, that would be one of the possible ways of improving performance here. I think it would still need more work to make sure that REST API call is triggered every time new post's content is saved. At the moment information about revisions doesn't get updated whenever a post is saved. This PR addresses it, too.

Yes, I'm aware of that, I'm just saying we may want to load the "last_revision_id" and "revision_count" in a separate endpoint instead of adding these as extra fields to the default POST endpoint. Because this change will change the result for everything and not only Gutenberg.

@youknowriad: it is another solution that would work. Again, we would need to find a way to refresh data each time post is saved.

@pento post data structure contains a list of categories or tags, why this is not the case for revisions? I'm sure there are reasons like we don't want to fetch everything and ruin performance. According to the documentation, we can pass context argument where one of the values is edit. It seems like a perfect match to our use case. So I would be happy to explore adding revisions to the REST API and enable it by default only in edit context.

Let's discuss here how we can improve the current solution - https://github.com/WordPress/gutenberg/pull/3233/files#diff-9dfc2b70ad1c71918441461179054b0bR386. REST API endpoint for post data is extended to serve also information about revisions. The downside of this approach is that it is now added to every REST API call that fetches post data.

@gziolo gziolo added Framework Issues related to broader framework topics, especially as it relates to javascript [Type] Enhancement A suggestion for improvement. labels Oct 31, 2017
@aduth aduth added the Core REST API Task Task for Core REST API efforts label Mar 1, 2018
@jeffpaul jeffpaul added this to the Merge Proposal milestone Mar 7, 2018
@mtias mtias added the [Priority] High Used to indicate top priority items that need quick attention label Mar 7, 2018
@mtias
Copy link
Member

mtias commented Mar 7, 2018

Marking this high priority for merge proposal.

@mtias mtias changed the title Framework: Improve the way we handle post revisions Framework: Improve how post revisions are handled Mar 7, 2018
@jeffpaul
Copy link
Member

This ticket was mentioned in Slack in #core-editor by jeffpaul. View the logs.

@mtias mtias modified the milestones: Merge Proposal, Merge Proposal: REST API Apr 12, 2018
@danielbachhuber
Copy link
Member

@gziolo Is this issue addressed by #6257, or are there other specific problems we need to address?

@gziolo
Copy link
Member Author

gziolo commented Apr 26, 2018

@danielbachhuber, I don't think it #6257 is directly related to this issue.

We had this issue where all revisions were loaded and cached inside HTML output just to read the url of the last revision and the total count of revisions. I added a hook which adds those 2 values to the post object which didn't seem ideal, but solved all performance issues. See https://github.com/WordPress/gutenberg/pull/3233/files#diff-9dfc2b70ad1c71918441461179054b0b in particular. This issue exists to find an alternative solution which would be included also in WP Core.

@danielbachhuber danielbachhuber self-assigned this Jun 4, 2018
@danielbachhuber
Copy link
Member

I've opened a core ticket for this: https://core.trac.wordpress.org/ticket/44321

Whatever conclusion we identify there, we can apply here in the interim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core REST API Task Task for Core REST API efforts Framework Issues related to broader framework topics, especially as it relates to javascript [Priority] High Used to indicate top priority items that need quick attention [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants