WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/23/2017 10:11:11 PM (3 years ago)
Author:
peterwilsoncc
Message:

Comments: Check if wp_new_comment() returns an error.

Adds checks throughout to allow for wp_new_comment() returning a WP_Error instance.

Updates the docs for the pre_comment_approved filter to include that it can be passed an error.

Props enrico.sorcinelli, ryotsun.
Fixes #39730.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-trackback.php

    r38791 r41980  
    127127    $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
    128128
    129     wp_new_comment($commentdata);
     129    $result = wp_new_comment( $commentdata );
     130
     131    if ( is_wp_error( $result ) ) {
     132        trackback_response( 1, $result->get_error_message() );
     133    }
     134
    130135    $trackback_id = $wpdb->insert_id;
    131136
Note: See TracChangeset for help on using the changeset viewer.