bobbingwide / oik-bwtrace

debug trace for WordPress
https://www.oik-plugins.com/oik-plugins/oik-bwtrace-debug-trace-for-wordpress/
GNU General Public License v2.0
6 stars 1 forks source link

Improve support for tracing REST API processing #52

Closed bobbingwide closed 4 years ago

bobbingwide commented 7 years ago

REST API requests are similar to AJAX requests.

When, for any reason, oik-bwtrace fails to open the trace output file Warning message is produced from fopen(). The documentation suggests that it's OK to suppress this warning with a preceding @. We should do this regardless of the type of request. I'll raise a separate issue.

It would be nice if REST requests could be traced to separate files. This depends on how early in the processing the REST_REQUEST constant is set to true. define( 'REST_REQUEST', true );

bobbingwide commented 6 years ago

With regards to tracing to separate files. REST_REQUEST is not defined until the end of processing for parse_request. This is well after trace has started. We could implement some code to pre-detect a REST request, by looking at $_SERVER['REQUEST_URI'], taking into account sub-directory installs,

The only thing we'll do differently at this stage is to start tracing to the 'rest' set of trace files instead of the normal set.

bobbingwide commented 6 years ago

At the end of REST processing, the filter rest_pre_echo_response allows us to see what's being returned to the client.

If rest tracing is enabled we can hook into this and simply call bw_trace2().

bobbingwide commented 4 years ago

Now doucmented: https://www.oik-plugins.com/wordpress-plugins-from-oik-plugins/free-oik-plugins/oik-trace-plugin/viewing-trace-files/viewing-rest-request-trace-files/