Ticket #11286: fix-http-status-in-comments.2.patch
File fix-http-status-in-comments.2.patch, 3.6 KB (added by , 15 years ago) |
---|
-
wp-comments-post.php
23 23 24 24 if ( empty($status->comment_status) ) { 25 25 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) ); 27 27 } elseif ( !comments_open($comment_post_ID) ) { 28 28 do_action('comment_closed', $comment_post_ID); 29 wp_die( __('Sorry, comments are closed for this item.') );29 wp_die( __('Sorry, comments are closed for this item.'), '', array('response' => 403) ); 30 30 } elseif ( in_array($status->post_status, array('draft', 'future', 'pending') ) ) { 31 31 do_action('comment_on_draft', $comment_post_ID); 32 exit;32 wp_die( __('Sorry, comments are closed for this item.'), '', array('response' => 403) ); 33 33 } elseif ( 'trash' == $status->post_status ) { 34 34 do_action('comment_on_trash', $comment_post_ID); 35 exit;35 wp_die( __('Sorry, comments are closed for this item.'), '', array('response' => 403) ); 36 36 } elseif ( post_password_required($comment_post_ID) ) { 37 37 do_action('comment_on_password_protected', $comment_post_ID); 38 exit;38 wp_die( __('Sorry, you must enter the password for this item.'), '', array('response' => 403) ); 39 39 } else { 40 40 do_action('pre_comment_on_post', $comment_post_ID); 41 41 } … … 61 61 } 62 62 } else { 63 63 if ( get_option('comment_registration') || 'private' == $status->post_status ) 64 wp_die( __('Sorry, you must be logged in to post a comment.') );64 wp_die( __('Sorry, you must be logged in to post a comment.'), '', array('response' => 403) ); 65 65 } 66 66 67 67 $comment_type = ''; 68 68 69 69 if ( get_option('require_name_email') && !$user->ID ) { 70 70 if ( 6 > strlen($comment_author_email) || '' == $comment_author ) 71 wp_die( __('Error: please fill the required fields (name, email).') );71 wp_die( __('Error: please fill the required fields (name, email).'), '', array('response' => 400) ); 72 72 elseif ( !is_email($comment_author_email)) 73 wp_die( __('Error: please enter a valid email address.') );73 wp_die( __('Error: please enter a valid email address.'), '', array('response' => 400) ); 74 74 } 75 75 76 if ( '' == $comment_content ) 77 wp_die( __('Error: please type a comment.') ); 76 if ( '' == $comment_content ) { 77 // User did not submit anything, bounce back to post. 78 $comment = NULL; 79 $location = empty($_POST['redirect_to']) ? get_permalink($comment_post_ID) : $_POST['redirect_to']; 80 $location = apply_filters('comment_post_redirect', $location, $comment); 81 wp_redirect($location); 82 exit; 83 } 78 84 79 85 $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0; 80 86 -
wp-includes/comment.php
550 550 if ( defined('DOING_AJAX') ) 551 551 die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); 552 552 553 wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!') );553 wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!'), '', array('response' => 400) ); 554 554 } 555 555 556 556 do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt ); … … 610 610 if ( defined('DOING_AJAX') ) 611 611 die( __('You are posting comments too quickly. Slow down.') ); 612 612 613 wp_die( __('You are posting comments too quickly. Slow down.'), '', array('response' => 40 3) );613 wp_die( __('You are posting comments too quickly. Slow down.'), '', array('response' => 400) ); 614 614 } 615 615 } 616 616 }