Opened 13 years ago
Closed 7 years ago
#25747 closed defect (bug) (fixed)
The `http_api_debug` hook isn't called for all HTTP requests
| Reported by: | johnbillion | Owned by: | johnbillion |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.3 |
| Component: | HTTP API | Version: | 2.7 |
| Severity: | minor | Keywords: | has-patch |
| Cc: | Focuses: |
Description (last modified by )
In WP_Http::_dispatch_request(), the http_api_debug action isn't called if there are no available transports for the request. This means we miss a situation that is ripe for debugging.
Edit: There's more. See my comments below.
Attachments (3)
Change History (11)
#3
@
13 years ago
- Description modified (diff)
- Keywords needs-patch added; has-patch removed
- Summary The `http_api_debug` hook isn't called when there are no available transports → The `http_api_debug` hook isn't called for all HTTP requests
There are actually several places where an HTTP request's return value doesn't trigger the http_api_debug action. None of the following responses trigger it:
- Anything short-circuiting requests with the
pre_http_requestfilter (here). - Invalid URLs (here).
- Blocked requests (here).
- Unwritable directories when streaming (here).
We might need a little refactoring here, or a helper method to trigger this action.
#5
@
11 years ago
- Keywords needs-testing needs-unit-tests has-patch added; needs-patch removed
25747.2.diff is a partial patch that I've had sitting around for ages. Probably needs some more work. And tests.
#8
@
7 years ago
- Keywords needs-patch added; needs-testing has-patch removed
- Milestone → Future Release
- Owner set to
- Status new → accepted
- Version 3.2 → 2.7
#9
@
7 years ago
- Keywords has-patch added; needs-unit-tests needs-patch removed
- Milestone Future Release → 5.3
25747.3.diff introduces a much simpler patch than prior ones. It calls the http_api_debug hook on all erroneous responses. There's no need to call the hook for errors being returned by pre_http_request because it's already catchable via that filter.
In addition, I've changed the error code for the error returned when requests are blocked so that loggers, debuggers, etc can differentiate between an unexpected error and an expected one.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
25747.diff (best viewed without whitespace changes) alters
_dispatch_request()so it doesn't return theWP_Errorimmediately. It then gets passed to thehttp_api_debughook as expected.Anything that's hooking into this hook will need to ensure it handles boolean
falseas the$classparameter, as well as a string.