Comments: Allow wp_update_comment() to return WP_Error().

The `wp_update_comment_data` filter introduced in 4.7 allows comment data to be filtered before it is updated in the database.

The patch aims to handle `WP_Error` as the filter above return value in a similar manner as is done for `wp_new_comment()`.


Fixes #39732.

Props: enricosorcinelli, swissspidy, gkloveweb, jnylen0, jbpaul17, afercia, SergeyBiryukov, audrasjb, imath, davidbaumwald.

Built from https://develop.svn.wordpress.org/trunk@48154


git-svn-id: http://core.svn.wordpress.org/trunk@47923 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
whyisjake
2020-06-24 00:05:12 +00:00
parent bb7a531b75
commit bb7601f6d0
7 changed files with 41 additions and 14 deletions

View File

@@ -3788,8 +3788,8 @@ class wp_xmlrpc_server extends IXR_Server {
$comment['comment_author_email'] = $content_struct['author_email'];
}
$result = wp_update_comment( $comment );
if ( is_wp_error( $result ) ) {
$result = wp_update_comment( $comment, true );
if ( is_wp_error( $result ) || false === $result ) {
return new IXR_Error( 500, $result->get_error_message() );
}