diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index 365c4f61ff..03d30b0e7a 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php @@ -431,10 +431,10 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { } /* - * Do not allow a comment to be created with an empty string for + * Do not allow a comment to be created with missing or empty * comment_content. See wp_handle_comment_submission(). */ - if ( '' === $prepared_comment['comment_content'] ) { + if ( empty( $prepared_comment['comment_content'] ) ) { return new WP_Error( 'rest_comment_content_invalid', __( 'Comment content is invalid.' ), array( 'status' => 400 ) ); } @@ -636,6 +636,10 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { return $prepared_args; } + if ( isset( $prepared_args['comment_content'] ) && empty( $prepared_args['comment_content'] ) ) { + return new WP_Error( 'rest_comment_content_invalid', __( 'Comment content is invalid.' ), array( 'status' => 400 ) ); + } + $prepared_args['comment_ID'] = $id; $check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_args ); @@ -1064,11 +1068,6 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { } } - // Require 'comment_content' unless only the 'comment_status' is being updated. - if ( ! empty( $prepared_comment ) && ! isset( $prepared_comment['comment_content'] ) ) { - return new WP_Error( 'rest_comment_content_required', __( 'Missing comment content.' ), array( 'status' => 400 ) ); - } - /** * Filters a comment after it is prepared for the database. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 1a2a0a2ace..3e20c58dce 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-beta2-39195'; +$wp_version = '4.7-beta2-39196'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.