Make WordPress Core

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

File fix-http-status-in-comments.11286.patch, 2.7 KB (added by mackensen, 11 years ago)

Refreshed, with some changes

  • src/wp-comments-post.php

    diff --git src/wp-comments-post.php src/wp-comments-post.php
    index 0ed359c..a5cb0f5 100644
    if ( ! comments_open( $comment_post_ID ) ) { 
    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' => 403 ) );
    5151} elseif ( 'trash' == $status ) {
    5252        /**
    5353         * Fires when a comment is attempted on a trashed post.
    if ( $user->exists() ) { 
    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' => 403 ) );
    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' => 200 ) );
    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' => 200 ) );
    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' => 200 ) );
    129129
    130130$comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
    131131
  • src/wp-includes/comment.php

    diff --git src/wp-includes/comment.php src/wp-includes/comment.php
    index a4cc7e2..fed94df 100644
    function wp_allow_comment( $commentdata ) { 
    843843                if ( defined( 'DOING_AJAX' ) ) {
    844844                        die( __('Duplicate comment detected; it looks as though you&#8217;ve already said that!') );
    845845                }
    846                 wp_die( __('Duplicate comment detected; it looks as though you&#8217;ve already said that!') );
     846                wp_die( __('Duplicate comment detected; it looks as though you&#8217;ve already said that!'), '', array('response' => 409) );
    847847        }
    848848
    849849        /**
    function check_comment_flood_db( $ip, $email, $date ) { 
    960960                        if ( defined('DOING_AJAX') )
    961961                                die( __('You are posting comments too quickly. Slow down.') );
    962962
    963                         wp_die( __('You are posting comments too quickly. Slow down.'), '', array('response' => 403) );
     963                        wp_die( __('You are posting comments too quickly. Slow down.'), '', array('response' => 429) );
    964964                }
    965965        }
    966966}