wp_debug_backtrace_summary( string $ignore_class = null, int $skip_frames = 0, bool $pretty = true ): string|array
- Since
- 3.4.0
- Source
wp-includes/functions.php:7241
Compatibility
- WordPress
- since 3.4.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$ignore_classstringoptional- A class to ignore all function calls within - useful when you want to just give info about the callee. Default null.Default:
null $skip_framesintoptional- A number of stack frames to skip - useful for unwinding back to the source of the issue. Default 0.Default:
0 $prettybooloptional- Whether you want a comma separated string instead of the raw array returned. Default true.Default:
true
Return value
string|array- Either a string containing a reversed comma separated trace or an array of individual calls.
Performance profile
How much work a call to wp_debug_backtrace_summary() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Light
- Scaling
- Scales with input
- Instructions
- 18–34
- Plugin surface
- None
- Called by
- 1
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 94.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What one call costs · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_debug_backtrace_summary() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
isset($truncate_paths) | 18–19 | debug_backtrace() |
isset($truncate_paths) | 22–23 | debug_backtrace(), array_reverse() |
!isset($truncate_paths) | 29–30 | debug_backtrace(), wp_normalize_path(), wp_normalize_path() |
!isset($truncate_paths) | 33–34 | debug_backtrace(), wp_normalize_path(), wp_normalize_path(), array_reverse() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 94 | 18–34 | 11 | |
| 8.5 | 94 | 18–34 | 11 | |
| 8.4 | 94 | 18–34 | 11 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 100 | 18–37 | 11 | |
| 8.2 | 100 | 18–37 | 11 | |
| 8.1 | 100 | 18–37 | 11 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 101 | 18–37 | 11 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 1
- wp_normalize_path()Normalizes a filesystem path.
Used by · 1
- wpdb::get_caller()Retrieves a comma-separated list of the names of the functions that called wpdb.
Source code
function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) { static $truncate_paths; $trace = debug_backtrace( false ); $caller = array(); $check_class = ! is_null( $ignore_class ); ++$skip_frames; // Skip this function. if ( ! isset( $truncate_paths ) ) { $truncate_paths = array( wp_normalize_path( WP_CONTENT_DIR ), wp_normalize_path( ABSPATH ), ); } foreach ( $trace as $call ) { if ( $skip_frames > 0 ) { --$skip_frames; } elseif ( isset( $call['class'] ) ) { if ( $check_class && $ignore_class === $call['class'] ) { continue; // Filter out calls. } $caller[] = "{$call['class']}{$call['type']}{$call['function']}"; } else { if ( in_array( $call['function'], array( 'do_action', 'apply_filters', 'do_action_ref_array', 'apply_filters_ref_array' ), true ) ) { $caller[] = "{$call['function']}('{$call['args'][0]}')"; } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ), true ) ) { $filename = isset( $call['args'][0] ) ? $call['args'][0] : ''; $caller[] = $call['function'] . "('" . str_replace( $truncate_paths, '', wp_normalize_path( $filename ) ) . "')"; } else { $caller[] = $call['function']; } } } if ( $pretty ) { return implode( ', ', array_reverse( $caller ) ); } else { return $caller; }}Changelog
Introduced in 3.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/functions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.