Make WordPress Core

Opened 10 years ago

Last modified 5 years ago

#27938 reviewing defect (bug)

Restore This Autosave does not work for custom post types that don't support 'revisions'

Reported by: bobbingwide's profile bobbingwide Owned by: chriscct7's profile chriscct7
Milestone: Future Release Priority: normal
Severity: normal Version: 3.8
Component: Revisions Keywords: has-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

If you have a custom post type that doesn't support revisions but you manage to create an autosave which is more recent than the current version then you get offered the opportunity to restore it, but the restore action doesn't complete. You end up in an annoying(*) loop.

Expected result: CPT restored to the autosave.
Actual result: Redirected to edit.php for the CPT

Steps to create the problem.

  1. Ensure your CPT doesn't support 'revisions'
  2. Create a new post and publish it
  3. Create an update but don't publish it... just let it autosave
  4. When you see the "Draft saved" message just quit
  5. Edit the post again.
  6. You will be shown the message:

There is an autosave of this post that is more recent than the version below.

  1. Click on the View the autosave link
  2. Click on Restore This Autosave button
  3. End up at the list of posts for this CPT.
  4. go to step 5.

Introduced by: #23497, change [23769]

Fixing this bug by simply reinstating the test on !wp_is_post_autosave( $revision ) leads to #27244 being applicable.
In my opinion, this follow on problem is preferable to the current behaviour.

Workaround for developers:
Define 'revisions' support for your CPTs... especially those which support 'editor'.

(*) What's annoying is that you get to see the autosaved version but it's not just a simple case of copying and pasting the text since the two versions get merged.

Attachments (1)

27938.diff (607 bytes) - added by bobbingwide 10 years ago.
Patch to reinstate test for autosave when post type doesn't support revisions

Download all attachments as: .zip

Change History (10)

10 years ago

Patch to reinstate test for autosave when post type doesn't support revisions

This ticket was mentioned in IRC in #wordpress-dev by bobbingwide. View the logs.

10 years ago

#2 @SergeyBiryukov
10 years ago

  • Description modified (diff)

#3 @SergeyBiryukov
10 years ago

  • Keywords has-patch added

#4 @adamsilverstein
10 years ago

This looks reasonable, I don't recall why the autosave check was removed.

This ticket was mentioned in IRC in #wordpress-dev by adamsilverstein. View the logs.

10 years ago

#6 @adamsilverstein
10 years ago

Indeed, autosaves are a special type of revision and currently you cannot correctly restore them if you have a CPT that doesn't support revisions - even if they are saved. And despite the fact that the message indicates you can. Wrong!

Your solution seems reasonable, another approach would be not doing autosaves for CPTs with revisions disabled;

Maybe the most robust solution would be to introduce an option supports->'autosaves' for custom post types and enable/disable based on that - that way autosaves gains a little autonomy, even if it is still a special type of revision in the back end.

#7 @chriscct7
9 years ago

  • Milestone changed from Awaiting Review to 4.4
  • Owner set to chriscct7
  • Status changed from new to reviewing

#8 @wonderboymusic
9 years ago

  • Milestone changed from 4.4 to Future Release

not new, shall punt

#10 @adamsilverstein
5 years ago

Leaving closed. I believe this is resolved in Gutenberg, if not we will work on a new issue there.

Note: See TracTickets for help on using tickets.