Testing $plugin->is_recording() before request has been resolved
Closed this issue · 2 comments
Calls to $plugin->is_recording()
run the request instance through the Clockwork ShouldRecord filters.
If the requests.slow_only
option is set to true
, those filters include a check of the response duration.
We don't sett the $request->responseTime
prop until we call $clockwork->resolveRequest()
from within the shutdown
hook. However, $plugin->is_recording()
is checked from within the plugins_loaded
hook to determine if Clockwork is currently enabled.
Effectively - setting requests.slow_only
to true currently disables Clockwork altogether.
I think it would be best to remove the slow_only setting altogether...
I don't think we can practically implement this without resorting to output buffering.
We need to run the incoming request through the should record filters to determine whether or not to send the clockwork headers. Without output buffering this has to happen before any output (i.e. temple_redirect or earlier).
But Request::$responseTime (which is what is needed for this feature to work) isn't available until the request is resolved on shutdown.
It's the same issue we faced with the server timing header and just an unfortunate reality we will probably face again due to the way WordPress is written vs. other modern PHP frameworks.
This is likely to affect the errors_only setting as well.