mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Customize: Add changeset locking in Customizer to prevent users from overriding each other's changes.
* Customization locking is checked when changesets are saved and when heartbeat ticks. * Lock is lifted immediately upon a user closing the Customizer. * Heartbeat is introduced into Customizer. * Changes made to user after it was locked by another user are stored as an autosave revision for restoration. * Lock notification displays link to preview the other user's changes on the frontend. * A user loading a locked Customizer changeset will be presented with an option to take over. * Autosave revisions attached to a published changeset are converted into auto-drafts so that they will be presented to users for restoration. * Focus constraining is improved in overlay notifications. * Escape key is stopped from propagating in overlay notifications, and it dismisses dismissible overlay notifications. * Introduces `changesetLocked` state which is used to disable the Save button and suppress the AYS dialog when leaving the Customizer. * Fixes bug where users could be presented with each other's autosave revisions. Props sayedwp, westonruter, melchoyce. See #31436, #31897, #39896. Fixes #42024. git-svn-id: https://develop.svn.wordpress.org/trunk@41839 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1455,7 +1455,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
),
|
||||
'autosave' => true,
|
||||
) );
|
||||
$this->assertFalse( wp_get_post_autosave( $changeset_post_id ) );
|
||||
$this->assertFalse( wp_get_post_autosave( $changeset_post_id, get_current_user_id() ) );
|
||||
$this->assertContains( 'Autosaved Auto-draft Title', get_post( $changeset_post_id )->post_content );
|
||||
|
||||
// Update status to draft for subsequent tests.
|
||||
@@ -1493,7 +1493,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'illegal_autosave_with_non_current_user', $r->get_error_code() );
|
||||
|
||||
// Try autosave.
|
||||
$this->assertFalse( wp_get_post_autosave( $changeset_post_id ) );
|
||||
$this->assertFalse( wp_get_post_autosave( $changeset_post_id, get_current_user_id() ) );
|
||||
$r = $wp_customize->save_changeset_post( array(
|
||||
'data' => array(
|
||||
'blogname' => array(
|
||||
@@ -1505,7 +1505,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertInternalType( 'array', $r );
|
||||
|
||||
// Verify that autosave happened.
|
||||
$autosave_revision = wp_get_post_autosave( $changeset_post_id );
|
||||
$autosave_revision = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
|
||||
$this->assertInstanceOf( 'WP_Post', $autosave_revision );
|
||||
$this->assertContains( 'Draft Title', get_post( $changeset_post_id )->post_content );
|
||||
$this->assertContains( 'Autosave Title', $autosave_revision->post_content );
|
||||
@@ -2635,6 +2635,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
'currentUserCanPublish',
|
||||
'publishDate',
|
||||
'statusChoices',
|
||||
'lockUser',
|
||||
),
|
||||
array_keys( $data['changeset'] )
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user