Make WordPress Core

Opened 18 years ago

Closed 17 years ago

Last modified 17 years ago

#5218 closed enhancement (fixed)

SAVEQUERIES: log calling function name

Reported by: tellyworth's profile tellyworth Owned by:
Milestone: 2.5 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: 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 (2)

wpdb-get-caller-r6256.diff (1.2 KB) - added by tellyworth 18 years ago.
wpdb-get-caller-r6256-a.diff (1.3 KB) - added by tellyworth 18 years ago.

Download all attachments as: .zip

Change History (11)

#1 @tellyworth
18 years ago

  • Keywords has-patch added

#2 @DD32
18 years ago

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

#3 @ryan
18 years ago

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.

#4 @tellyworth
18 years ago

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

#5 @foolswisdom
18 years ago

  • Milestone changed from 2.5 to 2.4

#6 @DD32
18 years ago

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.

#7 @ryan
17 years ago

  • Resolution set to fixed
  • Status changed from new to closed

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

#8 @matt
17 years ago

I like this!

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

#9 @ozh
17 years ago

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

Note: See TracTickets for help on using tickets.