Ticket #5218 (closed enhancement: fixed)
SAVEQUERIES: log calling function name
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.5 |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
The SAVEQUERIES constant tells wp-db to record SQL queries and execution time in the $wpdb->queries array. The included patch adds a third element to that array: the name of the function that called wpdb.
This makes it much easier to identify the code that caused a particular query to be run.
Attachments
Change History
debug_backtrace() is PHP 4.3+, WP requires PHP 4.2+
But Thats a nice addition which will be useful to some debuggers i'm sure.. another thought is what kind of performance hit is there when using debug_backtrace()?
It's a debug method that is not enabled by default, so performance isn't such a big deal. We can do a function exists check on debug_backtrace so we don't break 4.2 users who enable this.
comment:4
tellyworth — 4 years ago
wpdb-get-caller-r6256-a.diff adds an is_callable() check, and fixes up the style a little.
Another place which this would be useful is the SQL Errors, It'd be nice for the SQL error messages to include the function which is running the failing SQL.
- Status changed from new to closed
- Resolution set to fixed
I like this!
We should warn people about using it in production though, debug_backtrace can be SLOW.

