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/src/wp-includes/class-wp-customize-manager.php

    r48104 r48211  
    31403140        }
    31413141
    3142         if ( $changeset_post_id && ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->delete_post, $changeset_post_id ) ) {
    3143             wp_send_json_error(
    3144                 array(
    3145                     'code'    => 'changeset_trash_unauthorized',
    3146                     'message' => __( 'Unable to trash changes.' ),
    3147                 )
    3148             );
     3142        if ( $changeset_post_id ) {
     3143            if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->delete_post, $changeset_post_id ) ) {
     3144                wp_send_json_error(
     3145                    array(
     3146                        'code'    => 'changeset_trash_unauthorized',
     3147                        'message' => __( 'Unable to trash changes.' ),
     3148                    )
     3149                );
     3150            }
     3151
     3152            $lock_user = (int) wp_check_post_lock( $changeset_post_id );
     3153
     3154            if ( $lock_user && get_current_user_id() !== $lock_user ) {
     3155                wp_send_json_error(
     3156                    array(
     3157                        'code'     => 'changeset_locked',
     3158                        'message'  => __( 'Changeset is being edited by other user.' ),
     3159                        'lockUser' => $this->get_lock_user_data( $lock_user ),
     3160                    )
     3161                );
     3162            }
    31493163        }
    31503164
Note: See TracChangeset for help on using the changeset viewer.