REST API: Allow sending an empty or no-op comment update.
In general, updates that don't actually change anything should succeed. [39371] added tests for other object types, and this commit fixes empty updates for comments and adds the missing test. Fixes #38700. Built from https://develop.svn.wordpress.org/trunk@39597 git-svn-id: http://core.svn.wordpress.org/trunk@39537 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7d9b5b14b5
commit
7cc41e47ac
|
@ -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 ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.8-alpha-39596';
|
||||
$wp_version = '4.8-alpha-39597';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue