WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#35852 closed defect (bug) (fixed)

Starting Firefox, post edit tab restored: Revision is set to point where I started working in this tab the last time

Reported by: let me see... Owned by: azaozz
Milestone: 4.6 Priority: normal
Severity: normal Version: 4.4.2
Component: Editor Keywords: has-patch needs-testing
Focuses: Cc:
PR Number:

Description

This is a bit tricky to explain. I first noticed this about half a year ago (not sure when exactly). When I open my browser in the morning to work on an unfinished article, I do not in fact get the last version. Instead, I get the version of that point in time when I last started to work in this tab. So the complete history of changes in the last browser (tab) session is omitted. I always have to remind myself to reload the tab after starting FF, because only then I really get the latest revision on screen.

Today I forgot that, and edited the title and killed the permalink (deleted the line, clicking OK). Then I noticed some old stuff in the post which I had already deleted last night (before saving it) - but I had not reloaded yet. So, I reloaded the page (now without saving the post, of course).

However, what I ended up with was the old revision of the post (what I had been given this morning) with the new title (that I had changed without saving) and the old (!) permalink (which I had changed). And I could not restore the latest revision, because in the revision editor, it really showed me the latest version of yesterday night as current version. Which was crap, since after leaving the revision editor, I only got the old version again.

So, now I have to copy/paste all changes from the revision comparison to get to the latest saved version of yesterday night.

Attachments (1)

35852.patch (3.3 KB) - added by azaozz 4 years ago.

Download all attachments as: .zip

Change History (8)

#1 @Clorith
4 years ago

#36671 was marked as a duplicate.

#2 @Clorith
4 years ago

  • Component changed from General to Editor
  • Milestone changed from Awaiting Review to 4.6

I can also reliably reproduce this.

Steps to reproduce:

  • Make a new post, publish it and go back to wp-admin
  • Open the post for editing, make some changes
  • Click Update to update the post content
  • Click the View post link
  • Use the browser back button to return to the editor

It will now have the previous revision from before your latest edits, but not with the warning that there is a newer version available.

Hitting the browser refresh button will restore the latest entry.

I wonder if the autosave isn't being properly cleared when a post is updated.

#3 @azaozz
4 years ago

Can reproduce with the above steps.

Don't think this has anything to do with autosave. After a post is published autosave creates a special revision. We never load that revision, only show it on the revisions screen.

What is happening here is that when clicking on the Back button the browser loads the previous screen from (memory) cache. That cache was set when the screen was first loaded, i.e. with the post content before the user edited it.

In HTML 5 there is a way to detect when a page was loaded by pressing the Back or Forward button. Working on a patch.

@azaozz
4 years ago

#4 @azaozz
4 years ago

  • Keywords has-patch needs-testing added

35852.patch should fix this. It also fixes the partially related #28037, so the helper function post_form_autocomplete_off() for the old fix can be deprecated.

#5 @Clorith
4 years ago

Patch looks good on my end, unable to reproduce it any more on my setup.

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


4 years ago

#7 @azaozz
4 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 37619:

Editor: ensure the page is refreshed when the users navigate to it with the Back or Forward buttons. In these cases the browsers usually load the page from (memory) cache and it contains the old editor content.

Fixes #35852.

Note: See TracTickets for help on using tickets.