Customize: Ensure heartbeat keeps changeset locked when in branching mode.

Props dlh.
See #42024.
Merges [42612] to the 4.9 branch.
Fixes #42658.
Built from https://develop.svn.wordpress.org/branches/4.9@42623


git-svn-id: http://core.svn.wordpress.org/branches/4.9@42452 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2018-01-30 15:24:41 +00:00
parent 8d9813f6f6
commit dc9c4c4738
4 changed files with 17 additions and 5 deletions

View File

@ -8240,6 +8240,7 @@
// Check for lock when sending heartbeat requests.
$( document ).on( 'heartbeat-send.update_lock_notice', function( event, data ) {
data.check_changeset_lock = true;
data.changeset_uuid = api.settings.changeset.uuid;
} );
// Handle heartbeat ticks.

File diff suppressed because one or more lines are too long

View File

@ -3170,15 +3170,26 @@ final class WP_Customize_Manager {
* @return array The Heartbeat response.
*/
public function check_changeset_lock_with_heartbeat( $response, $data, $screen_id ) {
if ( array_key_exists( 'check_changeset_lock', $data ) && 'customize' === $screen_id && current_user_can( 'customize' ) && $this->changeset_post_id() ) {
$lock_user_id = wp_check_post_lock( $this->changeset_post_id() );
if ( isset( $data['changeset_uuid'] ) ) {
$changeset_post_id = $this->find_changeset_post_id( $data['changeset_uuid'] );
} else {
$changeset_post_id = $this->changeset_post_id();
}
if (
array_key_exists( 'check_changeset_lock', $data )
&& 'customize' === $screen_id
&& $changeset_post_id
&& current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id )
) {
$lock_user_id = wp_check_post_lock( $changeset_post_id );
if ( $lock_user_id ) {
$response['customize_changeset_lock_user'] = $this->get_lock_user_data( $lock_user_id );
} else {
// Refreshing time will ensure that the user is sitting on customizer and has not closed the customizer tab.
$this->refresh_changeset_lock( $this->changeset_post_id() );
$this->refresh_changeset_lock( $changeset_post_id );
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9.3-beta1-42622';
$wp_version = '4.9.3-beta1-42623';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.