Post edit collision detection fixes from mdawaffe. fixes #6043
git-svn-id: http://svn.automattic.com/wordpress/trunk@7146 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -472,8 +472,6 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
|
||||
check_ajax_referer( 'autosave', 'autosavenonce' );
|
||||
global $current_user;
|
||||
|
||||
$_POST['post_content'] = $_POST['content'];
|
||||
$_POST['post_excerpt'] = $_POST['excerpt'];
|
||||
$_POST['post_status'] = 'draft';
|
||||
$_POST['post_category'] = explode(",", $_POST['catslist']);
|
||||
$_POST['tags_input'] = explode(",", $_POST['tags_input']);
|
||||
@@ -521,7 +519,7 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
|
||||
die(__('You are not allowed to edit this post.'));
|
||||
}
|
||||
if ( $do_autosave ) {
|
||||
$id = wp_update_post($_POST);
|
||||
$id = edit_post();
|
||||
$data = $message;
|
||||
} else {
|
||||
$id = $post->ID;
|
||||
|
||||
@@ -151,6 +151,7 @@ if ( ( 'edit' == $action) && current_user_can('delete_post', $post_ID) )
|
||||
<br class="clear" />
|
||||
<?php if ($post_ID): ?>
|
||||
<?php printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); ?>
|
||||
<br class="clear" />
|
||||
<?php endif; ?>
|
||||
<span id="autosave"></span>
|
||||
</p>
|
||||
|
||||
@@ -129,6 +129,7 @@ if ( ('edit' == $action) && current_user_can('delete_page', $post_ID) )
|
||||
<br class="clear" />
|
||||
<?php if ($post_ID): ?>
|
||||
<?php printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); ?>
|
||||
<br class="clear" />
|
||||
<?php endif; ?>
|
||||
<span id="autosave"></span>
|
||||
</p>
|
||||
|
||||
@@ -113,6 +113,8 @@ function edit_post() {
|
||||
// Now that we have an ID we can fix any attachment anchor hrefs
|
||||
_fix_attachment_links( $post_ID );
|
||||
|
||||
wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID );
|
||||
|
||||
return $post_ID;
|
||||
}
|
||||
|
||||
@@ -321,6 +323,8 @@ function wp_write_post() {
|
||||
// Now that we have an ID we can fix any attachment anchor hrefs
|
||||
_fix_attachment_links( $post_ID );
|
||||
|
||||
wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID );
|
||||
|
||||
return $post_ID;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ case 'edit':
|
||||
if ( $last = wp_check_post_lock( $post->ID ) ) {
|
||||
$last_user = get_userdata( $last );
|
||||
$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
|
||||
$message = sprintf( __( '%s is currently editing this page' ), wp_specialchars( $last_user_name ) );
|
||||
$message = sprintf( __( 'Warning: %s is currently editing this page' ), wp_specialchars( $last_user_name ) );
|
||||
$message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
|
||||
add_action('admin_notices', create_function( '', "echo '$message';" ) );
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ case 'edit':
|
||||
if ( $last = wp_check_post_lock( $post->ID ) ) {
|
||||
$last_user = get_userdata( $last );
|
||||
$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
|
||||
$message = sprintf( __( '%s is currently editing this post' ), wp_specialchars( $last_user_name ) );
|
||||
$message = sprintf( __( 'Warning: %s is currently editing this post' ), wp_specialchars( $last_user_name ) );
|
||||
$message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
|
||||
add_action('admin_notices', create_function( '', "echo '$message';" ) );
|
||||
} else {
|
||||
|
||||
@@ -1215,6 +1215,10 @@ html, body {
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.submitbox #autosave .error {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
|
||||
#categorydiv #category-adder {
|
||||
|
||||
Reference in New Issue
Block a user