WordPress.org

Make WordPress Core

Ticket #11286: fix-http-status-in-comments.4.patch

File fix-http-status-in-comments.4.patch, 3.7 KB (added by miqrogroove, 4 years ago)

refreshed proper

  • wp-comments-post.php

     
    2323 
    2424if ( empty($post->comment_status) ) { 
    2525        do_action('comment_id_not_found', $comment_post_ID); 
    26         exit; 
     26        wp_die( __('Error: Request not understood. Please go back and try again.'), '', array('response' => 400) ); 
    2727} 
    2828 
    2929// get_post_status() will get the parent status for attachments. 
     
    3333 
    3434if ( !comments_open($comment_post_ID) ) { 
    3535        do_action('comment_closed', $comment_post_ID); 
    36         wp_die( __('Sorry, comments are closed for this item.') ); 
     36        wp_die( __('Sorry, comments are closed for this item.'), '', array('response' => 403) ); 
    3737} elseif ( 'trash' == $status ) { 
    3838        do_action('comment_on_trash', $comment_post_ID); 
    39         exit; 
     39        wp_die( __('Sorry, comments are closed for this item.'), '', array('response' => 403) ); 
    4040} elseif ( !$status_obj->public ) { 
    4141        do_action('comment_on_draft', $comment_post_ID); 
    42         exit; 
     42        wp_die( __('Sorry, comments are closed for this item.'), '', array('response' => 403) ); 
    4343} elseif ( post_password_required($comment_post_ID) ) { 
    4444        do_action('comment_on_password_protected', $comment_post_ID); 
    45         exit; 
     45        wp_die( __('Sorry, you must enter the password for this item.'), '', array('response' => 403) ); 
    4646} else { 
    4747        do_action('pre_comment_on_post', $comment_post_ID); 
    4848} 
     
    6868        } 
    6969} else { 
    7070        if ( get_option('comment_registration') || 'private' == $status ) 
    71                 wp_die( __('Sorry, you must be logged in to post a comment.') ); 
     71                wp_die( __('Sorry, you must be logged in to post a comment.'), '', array('response' => 403) ); 
    7272} 
    7373 
    7474$comment_type = ''; 
    7575 
    7676if ( get_option('require_name_email') && !$user->ID ) { 
    7777        if ( 6 > strlen($comment_author_email) || '' == $comment_author ) 
    78                 wp_die( __('Error: please fill the required fields (name, email).') ); 
     78                wp_die( __('Error: please fill the required fields (name, email).'), '', array('response' => 400) ); 
    7979        elseif ( !is_email($comment_author_email)) 
    80                 wp_die( __('Error: please enter a valid email address.') ); 
     80                wp_die( __('Error: please enter a valid email address.'), '', array('response' => 400) ); 
    8181} 
    8282 
    83 if ( '' == $comment_content ) 
    84         wp_die( __('Error: please type a comment.') ); 
     83if ( '' == $comment_content ) { 
     84        // User did not submit anything, bounce back to post. 
     85        $comment = NULL; 
     86        $location = empty($_POST['redirect_to']) ? get_permalink($comment_post_ID) : $_POST['redirect_to']; 
     87        $location = apply_filters('comment_post_redirect', $location, $comment); 
     88        wp_redirect($location); 
     89        exit; 
     90} 
    8591 
    8692$comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0; 
    8793 
  • wp-includes/comment.php

     
    557557                if ( defined('DOING_AJAX') ) 
    558558                        die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); 
    559559 
    560                 wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); 
     560                wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!'), '', array('response' => 400) ); 
    561561        } 
    562562 
    563563        do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt ); 
     
    617617                        if ( defined('DOING_AJAX') ) 
    618618                                die( __('You are posting comments too quickly.  Slow down.') ); 
    619619 
    620                         wp_die( __('You are posting comments too quickly.  Slow down.'), '', array('response' => 403) ); 
     620                        wp_die( __('You are posting comments too quickly.  Slow down.'), '', array('response' => 400) ); 
    621621                } 
    622622        } 
    623623}