Customize: Ensure autosave revision is dismissed immediately after implicit restoration notice dismissal as done with explicit notice dismissal.

Fixes issue where a drafted/scheduled changeset could inadvertently re-use the previous autosave revision in the preview while a user expects it to have been dismissed.

See #39896, [41597].
Fixes #42502 for 4.9.

Built from https://develop.svn.wordpress.org/branches/4.9@42145


git-svn-id: http://core.svn.wordpress.org/branches/4.9@41976 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-11-10 21:45:38 +00:00
parent af74789be0
commit 389166f9aa
3 changed files with 24 additions and 12 deletions

View File

@ -8248,7 +8248,7 @@
// Set up initial notifications. // Set up initial notifications.
(function() { (function() {
var removedQueryParams = []; var removedQueryParams = [], autosaveDismissed = false;
/** /**
* Obtain the URL to restore the autosave. * Obtain the URL to restore the autosave.
@ -8294,6 +8294,25 @@
history.replaceState( {}, document.title, urlParser.href ); history.replaceState( {}, document.title, urlParser.href );
} }
/**
* Dismiss autosave.
*
* @returns {void}
*/
function dismissAutosave() {
if ( autosaveDismissed ) {
return;
}
wp.ajax.post( 'customize_dismiss_autosave_or_lock', {
wp_customize: 'on',
customize_theme: api.settings.theme.stylesheet,
customize_changeset_uuid: api.settings.changeset.uuid,
nonce: api.settings.nonce.dismiss_autosave_or_lock,
dismiss_autosave: true
} );
autosaveDismissed = true;
}
/** /**
* Add notification regarding the availability of an autosave to restore. * Add notification regarding the availability of an autosave to restore.
* *
@ -8319,15 +8338,7 @@
} ); } );
// Handle dismissal of notice. // Handle dismissal of notice.
li.find( '.notice-dismiss' ).on( 'click', function() { li.find( '.notice-dismiss' ).on( 'click', dismissAutosave );
wp.ajax.post( 'customize_dismiss_autosave_or_lock', {
wp_customize: 'on',
customize_theme: api.settings.theme.stylesheet,
customize_changeset_uuid: api.settings.changeset.uuid,
nonce: api.settings.nonce.dismiss_autosave_or_lock,
dismiss_autosave: true
} );
} );
return li; return li;
} }
@ -8335,6 +8346,7 @@
// Remove the notification once the user starts making changes. // Remove the notification once the user starts making changes.
onStateChange = function() { onStateChange = function() {
dismissAutosave();
api.notifications.remove( code ); api.notifications.remove( code );
api.unbind( 'change', onStateChange ); api.unbind( 'change', onStateChange );
api.state( 'changesetStatus' ).unbind( onStateChange ); api.state( 'changesetStatus' ).unbind( onStateChange );

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9-RC2-42141'; $wp_version = '4.9-RC2-42145';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.