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 94d75cf42a..bd0c920c0f 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 @@ -664,6 +664,13 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { return $prepared_args; } + if ( ! empty( $prepared_args['comment_post_ID'] ) ) { + $post = get_post( $prepared_args['comment_post_ID'] ); + if ( empty( $post ) ) { + return new WP_Error( 'rest_comment_invalid_post_id', __( 'Invalid post ID.' ), array( 'status' => 403 ) ); + } + } + if ( empty( $prepared_args ) && isset( $request['status'] ) ) { // Only the comment status is being changed. $change = $this->handle_status_param( $request['status'], $id ); @@ -690,7 +697,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { $updated = wp_update_comment( wp_slash( (array) $prepared_args ) ); - if ( 0 === $updated ) { + if ( false === $updated ) { return new WP_Error( 'rest_comment_failed_edit', __( 'Updating comment failed.' ), array( 'status' => 500 ) ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 4cf8134f11..00ef2f560e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7.1-alpha-39627'; +$wp_version = '4.7.1-alpha-39628'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.