Send 403 instead of 500 for comment flood protection. Allow specifying response code for wp_die(). Props DD32. fixes #7246
git-svn-id: http://svn.automattic.com/wordpress/trunk@9335 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
002d07c3af
commit
e3517a9be4
|
@ -452,7 +452,7 @@ function check_comment_flood_db( $ip, $email, $date ) {
|
||||||
if ( defined('DOING_AJAX') )
|
if ( defined('DOING_AJAX') )
|
||||||
die( __('You are posting comments too quickly. Slow down.') );
|
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) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2208,10 +2208,14 @@ function wp_nonce_ays( $action ) {
|
||||||
*
|
*
|
||||||
* @param string $message Error message.
|
* @param string $message Error message.
|
||||||
* @param string $title Error title.
|
* @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;
|
global $wp_locale;
|
||||||
|
|
||||||
|
$defaults = array( 'response' => 500 );
|
||||||
|
$r = wp_parse_args($args, $defaults);
|
||||||
|
|
||||||
if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
|
if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
|
||||||
if ( empty( $title ) ) {
|
if ( empty( $title ) ) {
|
||||||
$error_data = $message->get_error_data();
|
$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 ( !function_exists( 'did_action' ) || !did_action( 'admin_head' ) ) :
|
||||||
if( !headers_sent() ){
|
if( !headers_sent() ){
|
||||||
status_header( 500 );
|
status_header( $r['response'] );
|
||||||
nocache_headers();
|
nocache_headers();
|
||||||
header( 'Content-Type: text/html; charset=utf-8' );
|
header( 'Content-Type: text/html; charset=utf-8' );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue