Autosave: prevent setting multiple stale wp-saving-post-* cookies when the browser disregards "session cookies" expiration on quit:
- Add expiration time of 24 hours for these cookies. - Rename them to `wp-saving-post` (no post_id) so there is never more than one cookie per domain. Fixes #29294. Built from https://develop.svn.wordpress.org/trunk@29572 git-svn-id: http://core.svn.wordpress.org/trunk@29346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -286,7 +286,7 @@ window.autosave = function() {
|
||||
});
|
||||
}
|
||||
|
||||
wpCookies.set( 'wp-saving-post-' + post_id, 'check' );
|
||||
wpCookies.set( 'wp-saving-post', post_id + '-check', 24 * 60 * 60 );
|
||||
});
|
||||
}
|
||||
|
||||
@@ -309,20 +309,17 @@ window.autosave = function() {
|
||||
function checkPost() {
|
||||
var content, post_title, excerpt, $notice,
|
||||
postData = getSavedPostData(),
|
||||
cookie = wpCookies.get( 'wp-saving-post-' + post_id );
|
||||
cookie = wpCookies.get( 'wp-saving-post' );
|
||||
|
||||
if ( ! postData ) {
|
||||
if ( cookie === post_id + '-saved' ) {
|
||||
wpCookies.remove( 'wp-saving-post' );
|
||||
// The post was saved properly, remove old data and bail
|
||||
setData( false );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( cookie ) {
|
||||
wpCookies.remove( 'wp-saving-post-' + post_id );
|
||||
|
||||
if ( cookie === 'saved' ) {
|
||||
// The post was saved properly, remove old data and bail
|
||||
setData( false );
|
||||
return;
|
||||
}
|
||||
if ( ! postData ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// There is a newer autosave. Don't show two "restore" notices at the same time.
|
||||
@@ -334,9 +331,8 @@ window.autosave = function() {
|
||||
post_title = $( '#title' ).val() || '';
|
||||
excerpt = $( '#excerpt' ).val() || '';
|
||||
|
||||
// cookie == 'check' means the post was not saved properly, always show #local-storage-notice
|
||||
if ( cookie !== 'check' && compare( content, postData.content ) &&
|
||||
compare( post_title, postData.post_title ) && compare( excerpt, postData.excerpt ) ) {
|
||||
if ( compare( content, postData.content ) && compare( post_title, postData.post_title ) &&
|
||||
compare( excerpt, postData.excerpt ) ) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
2
wp-includes/js/autosave.min.js
vendored
2
wp-includes/js/autosave.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user