[wp-trac] [WordPress Trac] #64260: Default filter `doing_it_wrong_trigger_error` for REST request cause no notice at all.

WordPress Trac noreply at wordpress.org
Mon Nov 17 03:39:50 UTC 2025


#64260: Default filter `doing_it_wrong_trigger_error` for REST request cause no
notice at all.
--------------------------+-----------------------------
 Reporter:  okvee         |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:  6.8.3
 Severity:  normal        |   Keywords:
  Focuses:  rest-api      |
--------------------------+-----------------------------
 File: **wp-includes/rest-api.php** inside function
 `rest_api_default_filters()` has this code.

 {{{
 if ( wp_is_serving_rest_request() ) {
     // ...
     add_filter( 'doing_it_wrong_trigger_error', '__return_false' );
 }
 }}}

 With this filter, all wrong calling code will not showing the notice
 anywhere including in **wp-content/debug.log**.

 For example:
 Function `register_rest_route()` (
 https://developer.wordpress.org/reference/functions/register_rest_route/
 ). There are many detection to call `_doing_it_wrong()` to notice
 developer to know that they are doing it wrong and let them fix it. These
 notices are useful and some can improve security.

 When I call function `register_rest_route()` without `permission_callback`
 argument, it should showing the notice about doing it wrong somewhere such
 as in debug.log.

 But inside function `_doing_it_wrong()`, your `if` condition:
 {{{
 if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true,
 $function_name, $message, $version ) )
 }}}

 calls to filter `doing_it_wrong_trigger_error` while this filter always
 return `false`. This cause function `_doing_it_wrong()` completely
 useless.

 Please consider change this default filter value or make it at least write
 the "doing it wrong" notice to **wp-content/debug.log** file.

 Tested with WordPress development version (6.9-RC1-61214).

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64260>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list