Make WordPress Core


Ignore:
Timestamp:
06/29/2020 10:31:12 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Customize: Do not allow changesets to be deleted when someone is editing them.

This makes the behavior consistent with that of locked posts, which can't be deleted via the list tables when another user is editing them.

Props dlh.
Fixes #50501.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/CustomizeManager.php

    r47122 r48211  
    514514        $this->assertEquals( 'changeset_trash_unauthorized', $this->_last_response_parsed['data']['code'] );
    515515        remove_filter( 'map_meta_cap', array( $this, 'return_do_not_allow' ) );
     516
     517        $lock_user_id  = static::factory()->user->create( array( 'role' => 'administrator' ) );
     518        $previous_user = get_current_user_id();
     519        wp_set_current_user( $lock_user_id );
     520        $wp_customize->set_changeset_lock( $wp_customize->changeset_post_id() );
     521        wp_set_current_user( $previous_user );
     522        $this->make_ajax_call( 'customize_trash' );
     523        $this->assertFalse( $this->_last_response_parsed['success'] );
     524        $this->assertEquals( 'changeset_locked', $this->_last_response_parsed['data']['code'] );
     525        delete_post_meta( $wp_customize->changeset_post_id(), '_edit_lock' );
    516526
    517527        wp_update_post(
Note: See TracChangeset for help on using the changeset viewer.