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.


git-svn-id: https://develop.svn.wordpress.org/trunk@48154 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock
2020-06-24 00:03:33 +00:00
parent 7a8d8a3e8a
commit ec062c08fe
9 changed files with 135 additions and 13 deletions

View File

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