Formatting: Don't overwrite the status header for Ajax responses that use output buffering or otherwise set their headers early.

Fixes #35666


git-svn-id: https://develop.svn.wordpress.org/trunk@38956 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn 2016-10-26 14:31:33 +00:00
parent 368d6ba190
commit 0dff84ad23

View File

@ -2880,9 +2880,10 @@ function _ajax_wp_die_handler( $message, $title = '', $args = array() ) {
); );
$r = wp_parse_args( $args, $defaults ); $r = wp_parse_args( $args, $defaults );
if ( ! headers_sent() ) { if ( ! headers_sent() && null !== $r['response'] ) {
status_header( $r['response'] ); status_header( $r['response'] );
} }
if ( is_scalar( $message ) ) if ( is_scalar( $message ) )
die( (string) $message ); die( (string) $message );
die( '0' ); die( '0' );
@ -3111,10 +3112,14 @@ function wp_send_json( $response, $status_code = null ) {
status_header( $status_code ); status_header( $status_code );
} }
echo wp_json_encode( $response ); echo wp_json_encode( $response );
if ( wp_doing_ajax() )
wp_die(); if ( wp_doing_ajax() ) {
else wp_die( '', '', array(
'response' => null,
) );
} else {
die; die;
}
} }
/** /**