Make WordPress Core

Ticket #55659: 55659.diff

File 55659.diff, 1.3 KB (added by sathyapulse, 4 years ago)
  • src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php
    index 0a2cf5d49b..326cafcc7e 100644
    a b class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { 
    220220                $prepared_post->ID = $post->ID;
    221221                $user_id           = get_current_user_id();
    222222
    223                 if ( ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status ) && $post->post_author == $user_id ) {
    224                         // Draft posts for the same author: autosaving updates the post and does not create a revision.
     223                /**
     224                 * Auto save updates the original post when the
     225                 * 1. post status is draft or auto-draft
     226                 * 2. post author is the current logged in user
     227                 * 3. current user holds the post lock
     228                 */
     229                if ( ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status ) && $post->post_author == $user_id && false === wp_check_post_lock( $post->ID ) ) {
    225230                        // Convert the post object to an array and add slashes, wp_update_post() expects escaped array.
    226231                        $autosave_id = wp_update_post( wp_slash( (array) $prepared_post ), true );
    227232                } else {