From 4a281919162c13eb0f86cb2b966cabc30dcc7ca4 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 24 Oct 2008 21:00:40 +0000 Subject: [PATCH] Send 403 instead of 500 for comment flood protection. Allow specifying response code for wp_die(). Props DD32. fixes #7246 git-svn-id: https://develop.svn.wordpress.org/trunk@9335 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/comment.php | 2 +- wp-includes/functions.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index d76fd7dffc..b33b817368 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -452,7 +452,7 @@ function check_comment_flood_db( $ip, $email, $date ) { if ( defined('DOING_AJAX') ) die( __('You are posting comments too quickly. Slow down.') ); - wp_die( __('You are posting comments too quickly. Slow down.') ); + wp_die( __('You are posting comments too quickly. Slow down.'), '', array('response' => 403) ); } } } diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 282bab9364..9ab187b901 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -2208,10 +2208,14 @@ function wp_nonce_ays( $action ) { * * @param string $message Error message. * @param string $title Error title. + * @param string|array $args Optional arguements to control behaviour. */ -function wp_die( $message, $title = '' ) { +function wp_die( $message, $title = '', $args = array() ) { global $wp_locale; + $defaults = array( 'response' => 500 ); + $r = wp_parse_args($args, $defaults); + if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { if ( empty( $title ) ) { $error_data = $message->get_error_data(); @@ -2245,7 +2249,7 @@ function wp_die( $message, $title = '' ) { if ( !function_exists( 'did_action' ) || !did_action( 'admin_head' ) ) : if( !headers_sent() ){ - status_header( 500 ); + status_header( $r['response'] ); nocache_headers(); header( 'Content-Type: text/html; charset=utf-8' ); }