WordPress.org

Make WordPress Core

#23960 closed defect (bug) (fixed)

Trigger local autosave when full save is initiated

Reported by: markjaquith Owned by: azaozz
Milestone: 3.6 Priority: high
Severity: major Version: 3.6
Component: Autosave Keywords:
Focuses: Cc:

Description

It appears that a fresh local autosave isn't triggered when you initiate a real update. So if something goes wrong, the version you'll be offered to restore may not be the version you had when you clicked the save/publish version.

Change History (5)

comment:1 azaozz15 months ago

It should be doing an explicit "save" on submitting the form: http://core.trac.wordpress.org/browser/trunk/wp-includes/js/autosave.js#L552

Perhaps there are JS errors (to see any errors and the logging of the saved content to the console, would need to make the console "sticky", i.e. keep content after reloading the page).

comment:2 markjaquith15 months ago

There are no JS errors.

To recreate:

  1. Open the post.
  2. Kill the server.
  3. Immediately add text then save.
  4. Restart the server.
  5. Load the post.

You don't be prompted to restore, because no local autosave happened.

comment:3 azaozz15 months ago

Trying to reproduce, may be missing something after step 3:

  1. Open the post.
  2. Kill the server.
  3. Immediately add text then save.

At this point the browser tries to submit the form. As the server is not available, it fails and shows its "Unable to connect" or "Oops! Google Chrome could not connect..." screen.

If the user clicks the browser's Back button, the Edit Post screen is shown again (from browser cache), local autosave kicks in, compares the content and shows the restore notice if different. However if the browser (tab/window) is closed, the local autosave data is removed as we use sessionStorage.

Navigating away (to another site), restarting the server, then navigating back to the same post in the same browser tab/window also triggers the restore notice.

Currently there is some debug logging to the browser console. When loading a post you can see the stored content (if any). When saving, you can see the saved content.

comment:4 markjaquith15 months ago

Reproduction:

http://txfx.s3.amazonaws.com/screencasts/autosave-before-manual-save.mov

You might have to try it a few times to trigger it.

comment:5 azaozz14 months ago

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

In 24328:

Local autosaves: always set 'autosave = true' in the post data when triggering local autosave on form submit. Fixes cases where the form is submitted shortly after loading the Edit screen, local autosave hasn't run yet and there is no previous data to be merged. Fixes #23960.

Note: See TracTickets for help on using tickets.