WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#36262 closed defect (bug) (fixed)

Page Restore Autosave Not Working

Reported by: jawad96 Owned by: adamsilverstein
Milestone: 4.6 Priority: normal
Severity: normal Version: 3.6
Component: Revisions Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

Hi there,

Restoring from Autosave on Pages is not working and I have similar symptoms to these users: https://wordpress.org/support/topic/restore-autosave-not-working?replies=3

Hence I think it may be a bug as other users are encountering similar problems.

Steps to reproduce:

1) Edit a published page

2) Let it autosave and exit the page without updating page.

3) Re-edit same page again and it will have the notification at the top: "There is an autosave of this post that is more recent than the version below. View the autosave"

4) Click on 'View the Autosave' link and then choose 'Restore This Autosave'

5) This causes the page to refresh/reload onto the 'Pages' menu.

6) If you check the page you attempted to restore from it has not been modified to reflect the restored autosave (i.e. it did not work restoring the page)

Please confirm if you can replicate and it is a bug or not?

Many Thank,
Jawad

Attachments (1)

36262.diff (631 bytes) - added by adamsilverstein 3 years ago.

Download all attachments as: .zip

Change History (15)

#1 @adamsilverstein
3 years ago

  • Keywords reporter-feedback added

@jawad96

Thanks for the bug report. I tested in trunk and was unable to reproduce this bug (I haven't tried 4.4.2)

I created and published a page, then made some changes which were autosaved. I left and revisited the page, followed the 'unsaved changes' warning link and clicked to restore the autosave. My autosaved changes where restored after clicking the 'Restore this Autosave' button.

Can you please try to see if this issue is reproducible with the default theme active and all plugins disabled?

Thanks.

#2 @jawad96
3 years ago

@adamsilverstein

Sorry for the late reply. I have been very ill the past week and slowly getting on top of things. I have managed to replicate this issue again. Please add

define('WP_POST_REVISIONS', false );

to your wp-config.php. Of course this code is used to prevent Wordpress from creating revisions. But it seems to have an adverse affect on the autosave.

Many Thanks,
Jawad

Last edited 3 years ago by jawad96 (previous) (diff)

#3 follow-up: @adamsilverstein
3 years ago

Ok, I will test again with revisions disabled this way, thanks for clearing that up. Be well!

#4 in reply to: ↑ 3 @jawad96
3 years ago

Replying to adamsilverstein:

Ok, I will test again with revisions disabled this way, thanks for clearing that up. Be well!

Cool, thanks. Let me know if you can also replicate on your end.

#5 @jawad96
3 years ago

Hello @adamsilverstein

Were you able to test this yet?

Many Thanks,
Jawad

#6 @jawad96
3 years ago

  • Keywords dev-feedback added; reporter-feedback removed

Hi @adamsilverstein ,

Any update on this request please? Were you able to replicate?

Many Thanks,
Jawad

#7 @adamsilverstein
3 years ago

@jawad96 Sorry I have been occupied with other things, getting back to revisions/autosave next week and will update here with what I find.

#8 @adamsilverstein
3 years ago

  • Owner set to adamsilverstein
  • Status changed from new to assigned

#9 @jawad96
3 years ago

Hey @adamsilverstein ,

Not to worry! Have you managed to test this yet? Interested to see if you are able to replicate.

Many Thanks,
Jawad

#10 @adamsilverstein
3 years ago

@jawad96 I was able to test this and confirm it is a bug, I am digging into why the autosave is not being restored. I do see it is being saved correctly, the restore process seems broken.

Thanks for the bug report!

#11 @adamsilverstein
3 years ago

  • Version changed from 4.4.2 to 3.6

I checked and this appears broken back at least as far as vs. 3.6, I see the same issue in that version.

#12 @adamsilverstein
3 years ago

  • Component changed from Autosave to Revisions
  • Keywords has-patch 2nd-opinion added; dev-feedback removed
  • Milestone changed from Awaiting Review to 4.6

@jawad96 Thanks again for the bug report.

I tracked this down to a flaw in the logic applied when restoring a revision. The code checks to make sure the revision you are attempting to restore is valid, and one check is for the 'WP_POST_REVISIONS' setting. Previously the code here allowed autosaves to be restored, but at some point in the past this logic was changed and autosaves were excluded - thus breaking the restore entirely if revisions are disabled (as you reported). I think we removed this because the use case you describe wasn't caught.

Fortunately, when we changed this, we left a comment in the code: Revisions disabled (previously checked autosaves && ! wp_is_post_autosave( $revision )) that made it pretty straightforward how to re-introduce the autosave check to the restore.

Can you test the attached patch to verify it resolves the issue for you? I tested on my end and the restore of my autosave now works properly with define('WP_POST_REVISIONS', false );

In 36262.diff:
Allow autosaves to be restored when revisions are disabled.

  • fixes the restore logic to allow restoring autosaves

I took some screencasts to visually record the issue:

Before patch:
http://cl.ly/3M1W3l1d0L1g

After patch:
http://cl.ly/0p0C120m1N44

#13 @lukecavanagh
3 years ago

I was able to test on a local truck version and it does look like a bug. The restored changes do show in the main editor, so when you do save the page. The restored auto save will be reflected back on the front-end.

#14 @ocean90
3 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 38009:

Revisions: Allow autosaves to be restored when revisions are disabled.

Fixes bug introduced in [23639] where autosaves are not restored if revisions are disabled.

Props adamsilverstein.
Fixes #36262.

Note: See TracTickets for help on using tickets.