WordPress.org

Make WordPress Core

Changeset 48218


Ignore:
Timestamp:
06/29/2020 11:40:56 PM (4 months ago)
Author:
SergeyBiryukov
Message:

Comments: Make wp_update_comment() return a WP_Error object for a canceled update, if $wp_error parameter is true.

Remove redundant checks for wp_update_comment() results being false, as the function always returns a WP_Error object now if $wp_error is true.

Follow-up to [48154], [48215], [48216].

See #39732.

Location:
trunk/src/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r48154 r48218  
    37903790
    37913791        $result = wp_update_comment( $comment, true );
    3792         if ( is_wp_error( $result ) || false === $result ) {
     3792        if ( is_wp_error( $result ) ) {
    37933793            return new IXR_Error( 500, $result->get_error_message() );
    37943794        }
  • trunk/src/wp-includes/comment.php

    r48216 r48218  
    25042504    $data = apply_filters( 'wp_update_comment_data', $data, $comment, $commentarr, $wp_error );
    25052505
     2506    if ( ! $data ) {
     2507        $data = new WP_Error( 'comment_update_canceled', __( 'Comment update canceled.' ) );
     2508    }
     2509
    25062510    // Do not carry on on failure.
    2507     if ( is_wp_error( $data ) || ! $data ) {
    2508         return $data;
     2511    if ( is_wp_error( $data ) ) {
     2512        if ( $wp_error ) {
     2513            return $data;
     2514        } else {
     2515            return false;
     2516        }
    25092517    }
    25102518
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    r48185 r48218  
    871871            $updated = wp_update_comment( wp_slash( (array) $prepared_args ), true );
    872872
    873             if ( is_wp_error( $updated ) || false === $updated ) {
     873            if ( is_wp_error( $updated ) ) {
    874874                return new WP_Error(
    875875                    'rest_comment_failed_edit',
Note: See TracChangeset for help on using the changeset viewer.