Comments: Make wp_update_comment() return a WP_Error object for a canceled update, if $wp_error parameter is true.

Remove redundant checks for `wp_update_comment()` results being `false`, as the function always returns a `WP_Error` object now if `$wp_error` is true.

Follow-up to [48154], [48215], [48216].

See #39732.
Built from https://develop.svn.wordpress.org/trunk@48218


git-svn-id: http://core.svn.wordpress.org/trunk@47987 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-06-29 23:42:03 +00:00
parent c6824c4330
commit f5942603c0
4 changed files with 13 additions and 5 deletions

View File

@ -3789,7 +3789,7 @@ class wp_xmlrpc_server extends IXR_Server {
}
$result = wp_update_comment( $comment, true );
if ( is_wp_error( $result ) || false === $result ) {
if ( is_wp_error( $result ) ) {
return new IXR_Error( 500, $result->get_error_message() );
}

View File

@ -2503,9 +2503,17 @@ function wp_update_comment( $commentarr, $wp_error = false ) {
*/
$data = apply_filters( 'wp_update_comment_data', $data, $comment, $commentarr, $wp_error );
if ( ! $data ) {
$data = new WP_Error( 'comment_update_canceled', __( 'Comment update canceled.' ) );
}
// Do not carry on on failure.
if ( is_wp_error( $data ) || ! $data ) {
return $data;
if ( is_wp_error( $data ) ) {
if ( $wp_error ) {
return $data;
} else {
return false;
}
}
$keys = array( 'comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP' );

View File

@ -870,7 +870,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
$updated = wp_update_comment( wp_slash( (array) $prepared_args ), true );
if ( is_wp_error( $updated ) || false === $updated ) {
if ( is_wp_error( $updated ) ) {
return new WP_Error(
'rest_comment_failed_edit',
__( 'Updating comment failed.' ),

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48217';
$wp_version = '5.5-alpha-48218';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.