[wp-trac] [WordPress Trac] #54832: _doing_it_wrong should write into debug.log
WordPress Trac
noreply at wordpress.org
Sun Jan 16 05:49:11 UTC 2022
#54832: _doing_it_wrong should write into debug.log
--------------------------+-----------------------------
Reporter: okvee | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 5.8.3
Severity: normal | Keywords:
Focuses: rest-api |
--------------------------+-----------------------------
I was created a plugin that called to `register_rest_route()` without
`permission_callback` argument. It worked fine until WordPress 5.5 that
this argument is now required.
However, the errors is not appears anywhere except in the REST API headers
but it is very hard to notice about that.
I keep using the old code because I didn't know about this change as it is
not showing in the debug.log.
Until one day that WordPress 5.8 released and I was entered to the new
widget management and BOOM!
All errors appears on the debug.log now.
This function (`_doing_it_wring()`) is useful and **should** write the
details into debug.log file no matter where it is called.
Example:
{{{
add_action('rest_api_init', 'myplugin_register_routes');
function myplugin_register_routes()
{
register_rest_route('myplugin', '/allitems', [
'args' => [
'mycustom' => 'args',
],
'methods' => \WP_REST_Server::READABLE,
'callback' => 'myplugin_get_items_function',
// 'permission_callback' => 'is_missing',// should always showing
error in debug.log
]);
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54832>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list