Ticket #11286: fix-http-status-in-comments.3.patch
| File fix-http-status-in-comments.3.patch, 3.6 KB (added by , 16 years ago) |
|---|
-
wp-comments-post.php
23 23 24 24 if ( empty($post->comment_status) ) { 25 25 do_action('comment_id_not_found', $comment_post_ID); 26 wp_die( __('Sorry, the item you are trying to comment on does not exist.'), '', array('response' => 400) ); 26 27 exit; 27 28 } 28 29 … … 33 34 34 35 if ( !comments_open($comment_post_ID) ) { 35 36 do_action('comment_closed', $comment_post_ID); 36 wp_die( __('Sorry, comments are closed for this item.') );37 wp_die( __('Sorry, comments are closed for this item.'), '', array('response' => 403) ); 37 38 } elseif ( 'trash' == $status ) { 38 39 do_action('comment_on_trash', $comment_post_ID); 40 wp_die( __('Sorry, comments are closed for this item.'), '', array('response' => 403) ); 39 41 exit; 40 42 } elseif ( !$status_obj->public ) { 41 43 do_action('comment_on_draft', $comment_post_ID); 44 wp_die( __('Sorry, comments are closed for this item.'), '', array('response' => 403) ); 42 45 exit; 43 46 } elseif ( post_password_required($comment_post_ID) ) { 44 47 do_action('comment_on_password_protected', $comment_post_ID); 48 wp_die( __('Sorry, the item you are trying to comment on is password-protected.'), '', array('response' => 403) ); 45 49 exit; 46 50 } else { 47 51 do_action('pre_comment_on_post', $comment_post_ID); … … 68 72 } 69 73 } else { 70 74 if ( get_option('comment_registration') || 'private' == $status ) 71 wp_die( __('Sorry, you must be logged in to post a comment.') );75 wp_die( __('Sorry, you must be logged in to post a comment.'), '', array('response' => 403) ); 72 76 } 73 77 74 78 $comment_type = ''; 75 79 76 80 if ( get_option('require_name_email') && !$user->ID ) { 77 81 if ( 6 > strlen($comment_author_email) || '' == $comment_author ) 78 wp_die( __('Error: please fill the required fields (name, email).') );82 wp_die( __('Error: please fill the required fields (name, email).'), '', array('response' => 400) ); 79 83 elseif ( !is_email($comment_author_email)) 80 wp_die( __('Error: please enter a valid email address.') );84 wp_die( __('Error: please enter a valid email address.'), '', array('response' => 400) ); 81 85 } 82 86 83 if ( '' == $comment_content ) 84 wp_die( __('Error: please type a comment.') ); 87 if ( '' == $comment_content ) { 88 // User did not submit anything, bounce back to post. 89 $comment = NULL; 90 $location = empty($_POST['redirect_to']) ? get_permalink($comment_post_ID) : $_POST['redirect_to']; 91 $location = apply_filters('comment_post_redirect', $location, $comment); 92 wp_redirect($location); 93 exit; 94 } 85 95 86 96 $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0; 87 97 -
wp-includes/comment.php
557 557 if ( defined('DOING_AJAX') ) 558 558 die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); 559 559 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) ); 561 561 } 562 562 563 563 do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt ); … … 617 617 if ( defined('DOING_AJAX') ) 618 618 die( __('You are posting comments too quickly. Slow down.') ); 619 619 620 wp_die( __('You are posting comments too quickly. Slow down.'), '', array('response' => 40 3) );620 wp_die( __('You are posting comments too quickly. Slow down.'), '', array('response' => 400) ); 621 621 } 622 622 } 623 623 }