From 51c0543bf25863148c846fe3342b9a4809e7173a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 11 Mar 2019 11:47:50 +0000 Subject: [PATCH] Bootstrap/Load: Add `nocache_headers()` to all `wp_die()` handlers. Props spacedmonkey. Fixes #46054. Built from https://develop.svn.wordpress.org/trunk@44828 git-svn-id: http://core.svn.wordpress.org/trunk@44660 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 16 ++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 383c0fedef..b2485fd22b 100644 --- a/wp-includes/functions.php +++ b/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 ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 10b0f42398..1c6f619acf 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.2-alpha-44827'; +$wp_version = '5.2-alpha-44828'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.