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. git-svn-id: https://develop.svn.wordpress.org/trunk@48218 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8b31484919
commit
99c3a2695b
@ -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() );
|
||||
}
|
||||
|
||||
|
@ -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' );
|
||||
|
@ -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.' ),
|
||||
|
Loading…
Reference in New Issue
Block a user