Make WordPress Core

Ticket #27248: comments-errors-400.diff

File comments-errors-400.diff, 1.7 KB (added by AmrMostafa, 11 years ago)

Use HTTP response code 400 instead of 500 for comment posting errors

  • wp-comments-post.php

     
    4747         * @param int $comment_post_ID Post ID.
    4848         */
    4949        do_action( 'comment_closed', $comment_post_ID );
    50         wp_die( __('Sorry, comments are closed for this item.') );
     50        wp_die( __('Sorry, comments are closed for this item.'), '', array('response' => 400) );
    5151} elseif ( 'trash' == $status ) {
    5252        /**
    5353         * Fires when a comment is attempted on a trashed post.
     
    112112        }
    113113} else {
    114114        if ( get_option('comment_registration') || 'private' == $status )
    115                 wp_die( __('Sorry, you must be logged in to post a comment.') );
     115                wp_die( __('Sorry, you must be logged in to post a comment.'), '', array('response' => 400) );
    116116}
    117117
    118118$comment_type = '';
    119119
    120120if ( get_option('require_name_email') && !$user->exists() ) {
    121121        if ( 6 > strlen($comment_author_email) || '' == $comment_author )
    122                 wp_die( __('<strong>ERROR</strong>: please fill the required fields (name, email).') );
     122                wp_die( __('<strong>ERROR</strong>: please fill the required fields (name, email).'), '', array('response' => 400) );
    123123        elseif ( !is_email($comment_author_email))
    124                 wp_die( __('<strong>ERROR</strong>: please enter a valid email address.') );
     124                wp_die( __('<strong>ERROR</strong>: please enter a valid email address.'), '', array('response' => 400) );
    125125}
    126126
    127127if ( '' == $comment_content )
    128         wp_die( __('<strong>ERROR</strong>: please type a comment.') );
     128        wp_die( __('<strong>ERROR</strong>: please type a comment.'), '', array('response' => 400) );
    129129
    130130$comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
    131131