From ae5940dd25dba8f2fdbf1f73c3fb4c51c15277cf Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 11 Mar 2019 11:46:41 +0000 Subject: [PATCH] Bootstrap/Load: Add `nocache_headers()` to all `wp_die()` handlers. Props spacedmonkey. Fixes #46054. git-svn-id: https://develop.svn.wordpress.org/trunk@44828 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 383c0fedef..b2485fd22b 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -3058,9 +3058,9 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) { if ( ! did_action( 'admin_head' ) ) : if ( ! headers_sent() ) { + header( 'Content-Type: text/html; charset=utf-8' ); status_header( $r['response'] ); nocache_headers(); - header( 'Content-Type: text/html; charset=utf-8' ); } $text_direction = $r['text_direction']; @@ -3238,6 +3238,7 @@ function _json_wp_die_handler( $message, $title = '', $args = array() ) { if ( null !== $r['response'] ) { status_header( $r['response'] ); } + nocache_headers(); } echo wp_json_encode( $data ); @@ -3265,6 +3266,10 @@ function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) { list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); + if ( ! headers_sent() ) { + nocache_headers(); + } + if ( $wp_xmlrpc_server ) { $error = new IXR_Error( $r['response'], $message ); $wp_xmlrpc_server->output( $error->getXml() ); @@ -3295,9 +3300,12 @@ function _ajax_wp_die_handler( $message, $title = '', $args = array() ) { list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); - // This is intentional. For backward-compatibility, support passing null here. - if ( ! headers_sent() && null !== $args['response'] ) { - status_header( $r['response'] ); + if ( ! headers_sent() ) { + // This is intentional. For backward-compatibility, support passing null here. + if ( null !== $args['response'] ) { + status_header( $r['response'] ); + } + nocache_headers(); } if ( is_scalar( $message ) ) {