Make WordPress Core

Opened 17 years ago

Closed 17 years ago

#3601 closed defect (bug) (fixed)

Autosave causes problems if it never receives a response

Reported by: mdawaffe's profile mdawaffe Owned by:
Milestone: 2.1 Priority: low
Severity: normal Version: 2.1
Component: Administration Keywords:
Focuses: Cc:


Since autosave disables the submit buttons, you can't save your data if it never gets a response from the server.

The button disabling was done to prevent collisions (multiple posts being created with same data), so we need a new way of preventing collisions.


  1. Re-enables buttons 1 second after disabling them.
  2. Keeps a record of the last 24 hours worth of post_IDs (and what temporary negative number from which they initially came).
  3. If you try to (auto)save a post with a negative post_ID, it first checks that record to see if that post has already been (auto)saved. If so, save that post under the real id.
  4. Autosave will silently forgo writing to the DB if the post was saved less than autosave_interval / 2 = 120 / 2 = 60 seconds ago.

This is accomplished by:

  1. new option: autosave_draft_ids
  2. a hack each in wp_write_post() and edit_post() (the functions defined in admin-functions.php).

Collisions are still *possible*, but much less likely.

Attachments (2)

3601.diff (5.1 KB) - added by mdawaffe 17 years ago.
autosave.diff (5.6 KB) - added by ryan 17 years ago.
Updated to use usermeta

Download all attachments as: .zip

Change History (5)

17 years ago

#1 @ryan
17 years ago

If two people are editing concurrently on the same blog, will there be contention when updating the autosave record? That's probably too corner-case to worry much about though.

#2 @mdawaffe
17 years ago

rboren: Just wondering if one might stomp the others changes to the array.
rboren: If they both get the array before the other writes.
mdawaffe: rboren: oh I see - yes that's possible
mdawaffe: I guess it could go in usermeta instead
rboren: Yeah, that's what I'm thinking.  Each user has his own autosave list.
mdawaffe: metakey = table_prefix . 'autosave_draft_ids'

17 years ago

Updated to use usermeta

#3 @ryan
17 years ago

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

(In [4760]) Autosave fixes from mdawaffe. fixes #3601

Note: See TracTickets for help on using tickets.