WordPress.org

Make WordPress Core

Changeset 48230


Ignore:
Timestamp:
06/30/2020 12:01:05 PM (4 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r48227 r48230  
    24912491     * Filters the comment data immediately before it is updated in the database.
    24922492     *
    2493      * Note: data being passed to the filter is already unslashed. Returning false
    2494      * or a WP_Error object would prevent the comment from being updated.
     2493     * Note: data being passed to the filter is already unslashed.
    24952494     *
    24962495     * @since 4.7.0
    2497      * @since 5.5.0 The `$wp_error` parameter was added.
    2498      *
    2499      * @param array $data       The new, processed comment data.
    2500      * @param array $comment    The old, unslashed comment data.
    2501      * @param array $commentarr The new, raw comment data.
    2502      * @param bool  $wp_error   Whether to return a WP_Error on failure.
    2503      */
    2504     $data = apply_filters( 'wp_update_comment_data', $data, $comment, $commentarr, $wp_error );
    2505 
    2506     if ( ! $data ) {
    2507         $data = new WP_Error( 'comment_update_canceled', __( 'Comment update canceled.' ) );
    2508     }
     2496     * @since 5.5.0 Returning a WP_Error value from the filter will short-circuit comment update
     2497     *              and allow skipping further processing.
     2498     *
     2499     * @param array|WP_Error $data       The new, processed comment data, or WP_Error.
     2500     * @param array          $comment    The old, unslashed comment data.
     2501     * @param array          $commentarr The new, raw comment data.
     2502     */
     2503    $data = apply_filters( 'wp_update_comment_data', $data, $comment, $commentarr );
    25092504
    25102505    // Do not carry on on failure.
Note: See TracChangeset for help on using the changeset viewer.