Fix two rare regressions: alert when the login has expires and when post is edited by another user, fixes #16928

git-svn-id: http://svn.automattic.com/wordpress/trunk@17640 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-04-16 02:37:44 +00:00
parent 03c3c94d1e
commit e4bf0a4e78
4 changed files with 18 additions and 17 deletions

View File

@ -916,7 +916,7 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
$do_autosave = (bool) $_POST['autosave'];
$do_lock = true;
$data = '';
$data = $alert = '';
/* translators: draft saved date format, see http://php.net/date */
$draft_saved_date_format = __('g:i:s a');
/* translators: %s: date and time */
@ -924,7 +924,7 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
$supplemental = array();
if ( isset($login_grace_period) )
$supplemental['session_expired'] = add_query_arg( 'interim-login', 1, wp_login_url() );
$alert .= sprintf( __('Your login has expired. Please open a new browser window and <a href="%s" target="_blank">login again</a>. '), add_query_arg( 'interim-login', 1, wp_login_url() ) );
$id = $revision_id = 0;
@ -939,12 +939,10 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
$last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
$data = new WP_Error( 'locked', sprintf(
$_POST['post_type'] == 'page' ? __( 'Autosave disabled: %s is currently editing this page.' ) : __( 'Autosave disabled: %s is currently editing this post.' ),
esc_html( $last_user_name )
) );
$data = __( 'Autosave disabled.' );
$supplemental['disable_autosave'] = 'disable';
$alert .= sprintf( __( '%s is currently editing this article. If you update it, you will overwrite the changes.' ), esc_html( $last_user_name ) );
}
if ( 'page' == $post->post_type ) {
@ -990,6 +988,9 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
}
}
if ( ! empty($alert) )
$supplemental['alert'] = $alert;
$x = new WP_Ajax_Response( array(
'what' => 'autosave',
'id' => $id,

View File

@ -1,4 +1,4 @@
var autosave, autosaveLast = '', autosavePeriodical, autosaveOldMessage = '', autosaveDelayPreview = false, notSaved = true, blockSave = false, interimLogin = false;
var autosave, autosaveLast = '', autosavePeriodical, autosaveOldMessage = '', autosaveDelayPreview = false, notSaved = true, blockSave = false;
jQuery(document).ready( function($) {
var dotabkey = true;
@ -83,7 +83,7 @@ jQuery(document).ready( function($) {
});
function autosave_parse_response(response) {
var res = wpAjax.parseAjaxResponse(response, 'autosave'), message = '', postID, sup, url;
var res = wpAjax.parseAjaxResponse(response, 'autosave'), message = '', postID, sup;
if ( res && res.responses && res.responses.length ) {
message = res.responses[0].data; // The saved message or error.
@ -94,13 +94,13 @@ function autosave_parse_response(response) {
autosave = function() {};
res = { errors: true };
}
if ( sup['session_expired'] && (url = sup['session_expired']) ) {
if ( !interimLogin || interimLogin.closed ) {
interimLogin = window.open(url, 'login', 'width=600,height=450,resizable=yes,scrollbars=yes,status=yes');
interimLogin.focus();
}
delete sup['session_expired'];
if ( sup['alert'] ) {
jQuery('#autosave-alert').remove();
jQuery('#titlediv').after('<div id="autosave-alert" class="error below-h2"><p>' + sup['alert'] + '</p></div>');
alert( jQuery('#autosave-alert').text() );
}
jQuery.each(sup, function(selector, value) {
if ( selector.match(/^replace-/) ) {
jQuery('#'+selector.replace('replace-', '')).val(value);
@ -131,7 +131,7 @@ function autosave_saved(response) {
// called when autosaving new post
function autosave_saved_new(response) {
blockSave = false;
var res = autosave_parse_response(response), tempID, postID;
var res = autosave_parse_response(response), postID;
if ( res && res.responses.length && !res.errors ) {
// An ID is sent only for real auto-saves, not for autosave=0 "keepalive" saves
postID = parseInt( res.responses[0].id, 10 );

File diff suppressed because one or more lines are too long

View File

@ -103,7 +103,7 @@ function wp_default_scripts( &$scripts ) {
'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};'
) );
$scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20110327' );
$scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20110415' );
$scripts->add_data( 'autosave', 'group', 1 );
$scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20101222' );