Ticket #5218 (closed enhancement: fixed)

Opened 1 year ago

Last modified 1 year ago

SAVEQUERIES: log calling function name

Reported by: tellyworth Assigned to: anonymous
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

wpdb-get-caller-r6256.diff (1.2 kB) - added by tellyworth on 10/17/07 01:56:19.
wpdb-get-caller-r6256-a.diff (1.3 kB) - added by tellyworth on 10/17/07 22:26:02.

Change History

10/17/07 01:56:19 changed by tellyworth

  • attachment wpdb-get-caller-r6256.diff added.

10/17/07 02:00:54 changed by tellyworth

  • keywords set to has-patch.

10/17/07 02:33:18 changed by DD32

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()?

10/17/07 18:39:00 changed by ryan

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.

10/17/07 22:26:02 changed by tellyworth

  • attachment wpdb-get-caller-r6256-a.diff added.

10/17/07 22:26:50 changed by tellyworth

wpdb-get-caller-r6256-a.diff adds an is_callable() check, and fixes up the style a little.

10/17/07 22:48:48 changed by foolswisdom

  • milestone changed from 2.5 to 2.4.

11/01/07 08:13:05 changed by DD32

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.

11/21/07 00:14:58 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [6342]) Debug backtrace for queries. Props tellyworth. fixes #5218

11/23/07 21:36:15 changed by matt

I like this!

We should warn people about using it in production though, debug_backtrace can be SLOW.

12/01/07 12:43:50 changed by ozh

Very great stuff! Can we have this for 2.3.2 even ?