Make WordPress Core

Opened 6 years ago

Closed 3 years ago

#44577 closed defect (bug) (worksforme)

After enabling revisions for post type, takes 2 additional revisions to show metabox on old posts.

Reported by: megabyterose's profile megabyterose Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.7
Component: Revisions Keywords:
Focuses: Cc:

Description

This is related to https://core.trac.wordpress.org/ticket/42500 but I specifically wanted to point out the difference between posts created prior to enabling support for revisions vs posts created after enabling support.

Revisions on posts prior to behave differently than posts created after enabling revisions.
Ones created prior to supporting revisions end up needing 3 revisions to display the metabox - the original, then the 2 after support is added (related to ticket 42500).
To recreate: https://youtu.be/HIxmfJkl5Jo

Found the problem here: https://wordpress.stackexchange.com/q/276389/84643

Change History (1)

#1 @adamsilverstein
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Hi @megabyterose thanks for the report,

This is actually expected behavior based on the current code. When you start a new post with revisions enabled you will get that initial revision/autodraft that counts as one. If you compare the two posts before making changes, there will already be two saved entries for the post where revisions are enabled for the type, while the post where revisions were not enabled will not have this stored revision, only the single saved entry. Now when you edit both posts, the one with revisions enabled initially will always have one additional revision. As pointed out elsewhere, you need to have more than one version for the UI to show.

Essentially until revisions are enabled for a post type, none will be saved. Once you enable it, it will take two saves for there to be a valid way to display the revisions screen (only one revision will match the current post, so nothing will show as "changed").

Ones created prior to supporting revisions end up needing 3 revisions to display the metabox - the original, then the 2 after support is added (related to ticket 42500).

Actually you still need 2, its just that the initial revision that is usually created when you start a post is not created, so you only have 1!

Given the fact that this is an edge case situation, I don't feel it justifies changing the code or trying to resolve directly. One possible improvement though would be documenting the requirements more clearly in the handbook where enabling revisions is explained (https://developer.wordpress.org/plugins/post-types/registering-custom-post-types/). If you want to help work on a change there I am happy to work on this.

Closing this ticket as "works for me" for now since this is expected behavior, please feel free to re-open if I have missed something.

Note: See TracTickets for help on using tickets.