WordPress.org

Make WordPress Core

Changeset 40782


Ignore:
Timestamp:
05/18/17 17:48:38 (2 months ago)
Author:
jnylen0
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r40667 r40782  
    482482 */ 
    483483function rest_handle_deprecated_function( $function, $replacement, $version ) { 
     484    if ( ! WP_DEBUG || headers_sent() ) { 
     485        return; 
     486    } 
    484487    if ( ! empty( $replacement ) ) { 
    485488        /* translators: 1: function name, 2: WordPress version number, 3: new function name */ 
     
    503506 */ 
    504507function rest_handle_deprecated_argument( $function, $message, $version ) { 
     508    if ( ! WP_DEBUG || headers_sent() ) { 
     509        return; 
     510    } 
    505511    if ( ! empty( $message ) ) { 
    506512        /* translators: 1: function name, 2: WordPress version number, 3: error message */ 
Note: See TracChangeset for help on using the changeset viewer.