Make WordPress Core


Ignore:
Timestamp:
10/23/2017 10:11:11 PM (7 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-admin/includes/ajax-actions.php

    r41978 r41980  
    11011101
    11021102    $comment_id = wp_new_comment( $commentdata );
     1103
     1104    if ( is_wp_error( $comment_id ) ) {
     1105        wp_die( $comment_id->get_error_message() );
     1106    }
     1107
    11031108    $comment = get_comment($comment_id);
    11041109    if ( ! $comment ) wp_die( 1 );
Note: See TracChangeset for help on using the changeset viewer.