From 21b1135b1c5759ecb9aaafbd57c32434d70069ea Mon Sep 17 00:00:00 2001 From: James Nylen Date: Thu, 18 May 2017 17:49:42 +0000 Subject: [PATCH] REST API: Do not set `X-WP-Deprecated*` headers as often. Only set these headers if (1) `WP_DEBUG` is enabled and (2) headers have not already been sent. Previously, this code could generate warnings by trying to set a header after response data has already been sent. This happens when code attached to the `shutdown` filter calls a deprecated function, for example. Also, these headers are unlikely to be useful in the majority of cases; let's only send them if `WP_DEBUG` is enabled. Props kraftbj, jnylen0, ocean90, rmccue. Fixes #40787. Built from https://develop.svn.wordpress.org/trunk@40782 git-svn-id: http://core.svn.wordpress.org/trunk@40640 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api.php | 6 ++++++ wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index 57e4e9f6fd..c831fed7ec 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -481,6 +481,9 @@ function rest_ensure_response( $response ) { * @param string $version Version. */ function rest_handle_deprecated_function( $function, $replacement, $version ) { + if ( ! WP_DEBUG || headers_sent() ) { + return; + } if ( ! empty( $replacement ) ) { /* translators: 1: function name, 2: WordPress version number, 3: new function name */ $string = sprintf( __( '%1$s (since %2$s; use %3$s instead)' ), $function, $version, $replacement ); @@ -502,6 +505,9 @@ function rest_handle_deprecated_function( $function, $replacement, $version ) { * @param string $version Version. */ function rest_handle_deprecated_argument( $function, $message, $version ) { + if ( ! WP_DEBUG || headers_sent() ) { + return; + } if ( ! empty( $message ) ) { /* translators: 1: function name, 2: WordPress version number, 3: error message */ $string = sprintf( __( '%1$s (since %2$s; %3$s)' ), $function, $version, $message ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 96d9d2575d..8eca71e06d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-beta1-40781'; +$wp_version = '4.8-beta1-40782'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.