WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#19589 closed defect (bug) (fixed)

Simplify the recording of backtraces

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

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 6 years ago.
Implementation of a new wp_debug_backtrace_summary() function

Download all attachments as: .zip

Change History (8)

@westi
6 years ago

Implementation of a new wp_debug_backtrace_summary() function

#1 @scribu
6 years ago

  • Cc scribu added

#2 @scribu
6 years ago

  • Keywords has-patch added; needs-patch removed

#3 @westi
6 years ago

  • Milestone changed from Future Release to 3.4

#4 follow-up: @nacin
6 years 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.

#5 in reply to: ↑ 4 @westi
6 years 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.

#6 @westi
6 years ago

  • 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

#7 @westi
6 years ago

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.