Opened 12 years ago
Closed 10 years ago
#22117 closed enhancement (wontfix)
Better backtrace
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4.2 |
Component: | Database | Keywords: | needs-refresh dev-feedback |
Focuses: | Cc: |
Description
Hey,
This is a small hack for a prettier backtrace info.
the file /wp-includes/functions.php at Line 3547
the new functions with added lines
function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) { if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) $trace = debug_backtrace( false ); else $trace = debug_backtrace(); $caller = array(); $check_class = ! is_null( $ignore_class ); $skip_frames++; // skip this function $last_info = array(); foreach ( $trace as $call ) { if ( isset( $call['class'] ) && 'wpdb' == $call['class'] ) { $last_info['file'] = basename($call['file']); $last_info['line'] = $call['line']; } 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']}"; if( empty( $last_info['func'] ) ) $last_info['func'] = $call['class'].'->'.$call['function']; } else { if ( in_array( $call['function'], array( 'do_action', 'apply_filters' ) ) ) { $caller[] = "{$call['function']}('{$call['args'][0]}')"; } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) { $caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) , '', $call['args'][0] ) . "')"; } else { $caller[] = $call['function']; if( empty( $last_info['func'] ) ) $last_info['func'] = $call['function']; } } } if ( $pretty ) return sprintf(__("Error at %s, at line %d, in function %s<br/>%s"), $last_info['file'], $last_info['line'], $last_info['func'], join( ', ', array_reverse( $caller ) ) ); else return $caller; }
Attachments (1)
Change History (6)
#2
in reply to:
↑ 1
@
12 years ago
Replying to scribu:
sorry new around here, will look into the link :)
#5
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
This just wraps the output of wp_debug_backtrace_summary()
in Error at {file}, at line {line}, in function {function}<br/>{backtrace}
which a) isn't accurate because backtraces aren't just used for errors, and b) will break any existing code which is exploding the output by commas.
Not worth the effort, testing, etc.
Note: See
TracTickets for help on using
tickets.
Related: #19589
It would be nice if you could submit your addition in patch form: http://core.trac.wordpress.org/wiki#HowtoSubmitPatches