WordPress.org

Make WordPress Core

Changeset 30579


Ignore:
Timestamp:
11/26/2014 08:16:47 PM (7 years ago)
Author:
ocean90
Message:

Comments: Use proper HTTP response codes for validation errors.

props miqrogroove, solarissmoke, mackensen.
fixes #11286.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-comments-post.php

    r28672 r30579  
    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.' ), 403 );
    5151} elseif ( 'trash' == $status ) {
    5252    /**
     
    112112    }
    113113} else {
    114     if ( get_option('comment_registration') || 'private' == $status )
    115         wp_die( __('Sorry, you must be logged in to post a comment.') );
     114    if ( get_option( 'comment_registration' ) || 'private' == $status ) {
     115        wp_die( __( 'Sorry, you must be logged in to post a comment.' ), 403 );
     116    }
    116117}
    117118
     
    119120
    120121if ( get_option('require_name_email') && !$user->exists() ) {
    121     if ( 6 > strlen($comment_author_email) || '' == $comment_author )
    122         wp_die( __('<strong>ERROR</strong>: please fill the required fields (name, email).') );
    123     elseif ( !is_email($comment_author_email))
    124         wp_die( __('<strong>ERROR</strong>: please enter a valid email address.') );
     122    if ( 6 > strlen( $comment_author_email ) || '' == $comment_author ) {
     123        wp_die( __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), 200 );
     124    } else if ( ! is_email( $comment_author_email ) ) {
     125        wp_die( __( '<strong>ERROR</strong>: please enter a valid email address.' ), 200 );
     126    }
    125127}
    126128
    127 if ( '' == $comment_content )
    128     wp_die( __('<strong>ERROR</strong>: please type a comment.') );
     129if ( '' == $comment_content ) {
     130    wp_die( __( '<strong>ERROR</strong>: please type a comment.' ), 200 );
     131}
    129132
    130133$comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
  • trunk/src/wp-includes/comment.php

    r30402 r30579  
    11321132            die( __('Duplicate comment detected; it looks as though you&#8217;ve already said that!') );
    11331133        }
    1134         wp_die( __('Duplicate comment detected; it looks as though you&#8217;ve already said that!') );
     1134        wp_die( __( 'Duplicate comment detected; it looks as though you&#8217;ve already said that!' ), 409 );
    11351135    }
    11361136
     
    12501250                die( __('You are posting comments too quickly. Slow down.') );
    12511251
    1252             wp_die( __('You are posting comments too quickly. Slow down.'), '', array('response' => 403) );
     1252            wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 );
    12531253        }
    12541254    }
Note: See TracChangeset for help on using the changeset viewer.