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
This commit is contained in:
Sergey Biryukov 2020-06-30 12:01:05 +00:00
parent 3e1f66bb2e
commit 595a799da0

View File

@ -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 ) ) {