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.
Built from https://develop.svn.wordpress.org/trunk@48230


git-svn-id: http://core.svn.wordpress.org/trunk@47999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-06-30 12:03:04 +00:00
parent 265239b2e5
commit 8ac810e460
2 changed files with 8 additions and 13 deletions

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

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48229';
$wp_version = '5.5-alpha-48230';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.