From 595a799da015ade255f2b5737aabc16271cc6aeb Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 30 Jun 2020 12:01:05 +0000 Subject: [PATCH] Comments: Add a `@since` note to the `wp_update_comment_data` filter about returning a `WP_Error` value. Remove the ability to short-circuit comment update by returning `false` from the filter for now. This was inconsistent with the `pre_comment_approved` filter, and should not be necessary if a more descriptive reason can be given by always using `WP_Error`. See #39732. git-svn-id: https://develop.svn.wordpress.org/trunk@48230 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 8a64a530dc..9868d62c23 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2490,22 +2490,17 @@ function wp_update_comment( $commentarr, $wp_error = false ) { /** * Filters the comment data immediately before it is updated in the database. * - * Note: data being passed to the filter is already unslashed. Returning false - * or a WP_Error object would prevent the comment from being updated. + * Note: data being passed to the filter is already unslashed. * * @since 4.7.0 - * @since 5.5.0 The `$wp_error` parameter was added. + * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update + * and allow skipping further processing. * - * @param array $data The new, processed comment data. - * @param array $comment The old, unslashed comment data. - * @param array $commentarr The new, raw comment data. - * @param bool $wp_error Whether to return a WP_Error on failure. + * @param array|WP_Error $data The new, processed comment data, or WP_Error. + * @param array $comment The old, unslashed comment data. + * @param array $commentarr The new, raw comment data. */ - $data = apply_filters( 'wp_update_comment_data', $data, $comment, $commentarr, $wp_error ); - - if ( ! $data ) { - $data = new WP_Error( 'comment_update_canceled', __( 'Comment update canceled.' ) ); - } + $data = apply_filters( 'wp_update_comment_data', $data, $comment, $commentarr ); // Do not carry on on failure. if ( is_wp_error( $data ) ) {