Opened 17 months ago

Closed 16 months ago

Last modified 16 months ago

#19589 closed defect (bug) (fixed)

Simplify the recording of backtraces

Reported by: westi Owned by: westi
Priority: normal Milestone: 3.4
Component: Warnings/Notices Version: 3.3
Severity: normal Keywords: early has-patch
Cc: scribu

Description

We currently have a simple backtrace generator in wpdb::get_caller which doesn't always tell the complete truth (e.g. when object methods are called statically this is not shown) and is limited to use from the wpdb object.

We should have a more generic function available in core which wpdb and plugins (like debug bar can use)

Attachments (1)

simpler-backtraces-core.diff (2.2 KB) - added by westi 17 months ago.
Implementation of a new wp_debug_backtrace_summary() function

Download all attachments as: .zip

Change History (8)

westi17 months ago

Implementation of a new wp_debug_backtrace_summary() function

  • Cc scribu added
  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Future Release to 3.4

comment:4 follow-up: ↓ 5   nacin16 months ago

I think it would be better for the function to return an array that can then be imploded. For example someone may wish to turn this into a list, or reverse it first, before printing it. The comma is a bit hard-coded in.

Beyond that, +1.

comment:5 in reply to: ↑ 4   westi16 months ago

Replying to nacin:

I think it would be better for the function to return an array that can then be imploded. For example someone may wish to turn this into a list, or reverse it first, before printing it. The comma is a bit hard-coded in.

Beyond that, +1.

I specifically avoided returning the array for a number of reasons:

  • I was trying to refactor the code out of WPDB and make it more generally usable so wanted it to be a drop-in replacement in terms of functionality
  • I wanted to encourage consistent display and ordering of the data across use-cases - so that you can look at the displayed trace and see it exactly.
  • When you display the backtrace not imploded you want to display more info like line numbers now you have the space for them

However, I can see that adding a 3rd argument $pretty which defaults to true and current behaviour and otherwise returns the array if false is a simple and clean thing to do so I'm not averse to doing it and will include it.

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

In [19773]:

Refactor WPDB::get_caller() into wp_debug_backtrace_summary() and improve the functionality to provide enhanced context and a standardised default pretty format. Fixes #19589

In [19774]:

Fix my spelling mistakes and typos in the wp_debug_backtrace_summary() phpDoc props duck_ see #19589.

Note: See TracTickets for help on using tickets.