wp_insert_comment() and wp_new_comment() should check if the comment was successfully inserted into the database.

props pento.
fixes #28254.
Built from https://develop.svn.wordpress.org/trunk@28672


git-svn-id: http://core.svn.wordpress.org/trunk@28490 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov
2014-06-05 04:38:14 +00:00
parent dbff41578e
commit 02657dcd66
2 changed files with 13 additions and 4 deletions

View File

@@ -132,7 +132,11 @@ $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_paren
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
$comment_id = wp_new_comment( $commentdata );
$comment = get_comment($comment_id);
if ( ! $comment_id ) {
wp_die( __( "<strong>ERROR</strong>: The comment could not be saved. Please try again later." ) );
}
$comment = get_comment( $comment_id );
/**
* Perform other actions when comment cookies are set.