[wp-trac] [WordPress Trac] #6043: Post Edit Collision Detection
WordPress Trac
wp-trac at lists.automattic.com
Fri Feb 29 09:21:09 GMT 2008
#6043: Post Edit Collision Detection
----------------------------+-----------------------------------------------
Reporter: mdawaffe | Owner: anonymous
Type: enhancement | Status: new
Priority: normal | Milestone: 2.5
Component: Administration | Version: 2.5
Severity: normal | Keywords: has-patch needs-testing
----------------------------+-----------------------------------------------
When multiple people edit the same post, the last person to save
overwrites everyone else's work. It's worse if the post is a draft;
autosave stomps all over everyone's work.
This happens with surprising frequency on high traffic, multi author
blogs.
Proposal:
Store in postmeta who last edited a post, and when that person edited it.
Use that information as a "post lock". Keep the post lock fresh by
updating it during autosave. If another person tries to edit a post while
the post is locked, display a warning.
Attached Implementation:
1. Autosave currently fires every 60 seconds but only if there's some new
change in the post to save. Change autosave to fire every 60 seconds no
matter what (but only actually write to the DB if there are changes to the
post).
2. Define that 60 seconds in a new option: {{{get_option(
'autosave_interval' );}}}.
3. New function: {{{wp_check_post_lock()}}} checks to see if a post is
locked and by whom. A post lock is considered fresh (and the post locked)
if the lock is no older than {{{autosave_interval * 2}}} seconds old.
4. New function: {{{wp_set_post_lock()}}} locks or refreshes lock.
5. Whenever a person starts editing a post, set lock with
{{{wp_set_post_lock()}}}.
6. During each autosave, refresh lock with {{{wp_set_post_lock()}}}.
7. When someone else goes to edit that post, if
{{{wp_check_post_lock()}}}, display warning with {{{admin_notices}}} and
disable autosave.
8. When someone else tries to autosave, if {{{wp_check_post_lock()}}},
display warning via ajax and disable autosave.
9. Client side of Ajax handled by beefed up wp-ajax-response JS (move to
its own file from wp-list.js).
After patching
{{{
svn add wp-includes/js/wp-ajax-response.js
}}}
Notes:
1. Locks can only be kept fresh via the periodic ajax call (autosave).
Locks cannot be kept fresh if you don't have JS.
2. If the user doesn't have JS, the lock is still set when the post edit
page is loaded. Since we know when the post was last modified
({{{post_modified}}}), we could show some kind of message if there's an
old (non-fresh) lock that is newer than the {{{post_modified}}} and
"somewhat recent". Like 5 or 10 minutes or something. That logic and UI
gets complicated and confusing, though.
--
Ticket URL: <http://trac.wordpress.org/ticket/6043>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list