Make WordPress Core


Ignore:
Timestamp:
06/24/2020 12:03:33 AM (4 years ago)
Author:
whyisjake
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    r47850 r48154  
    869869            }
    870870
    871             $updated = wp_update_comment( wp_slash( (array) $prepared_args ) );
    872 
    873             if ( false === $updated ) {
     871            $updated = wp_update_comment( wp_slash( (array) $prepared_args ), true );
     872
     873            if ( is_wp_error( $updated ) || false === $updated ) {
    874874                return new WP_Error(
    875875                    'rest_comment_failed_edit',
Note: See TracChangeset for help on using the changeset viewer.