[wp-trac] [WordPress Trac] #44534: wp_debug_mode() does not turn off display_errors for REST requests

WordPress Trac noreply at wordpress.org
Wed Oct 10 14:20:13 UTC 2018


#44534: wp_debug_mode() does not turn off display_errors for REST requests
--------------------------+-----------------------------
 Reporter:  chrisl27      |       Owner:  SergeyBiryukov
     Type:  defect (bug)  |      Status:  reviewing
 Priority:  normal        |   Milestone:  5.0
Component:  REST API      |     Version:  4.5
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  rest-api
--------------------------+-----------------------------

Comment (by duanestorey):

 Another possibly way to maybe approach this is to modify wp_debug_mode()
 directly and disable display errors when a request header such as

 Accept: application/json

 is present. I doesn't make any sense to output debug in that case.

 The wp_debug_mode() function already does this for several different
 scenarios:

  if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || (
 defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() ) {

 So perhaps we can add a new one, something like:

  if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || (
 defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() ||
 wp_is_json_request() ) {

 where wp_is_json_request() would check $_SERVER[ 'HTTP_ACCEPT' ] in PHP.

 Thoughts?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44534#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list