From f6de9b77f83438ca1bbeffe85a7296674960714d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 8 Mar 2018 17:07:04 +0000 Subject: [PATCH] =?UTF-8?q?General:=20In=20`wp=5Fdebug=5Fbacktrace=5Fsumma?= =?UTF-8?q?ry()`,=20normalize=20paths=20before=20replacement=20for=20bette?= =?UTF-8?q?r=20cross=E2=80=93platform=20compatibility.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Props Rarst. Fixes #43501. git-svn-id: https://develop.svn.wordpress.org/trunk@42800 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index f3afe60a9c..ba56521cf3 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -5366,6 +5366,8 @@ function wp_allowed_protocols() { * * @see https://core.trac.wordpress.org/ticket/19589 * + * @staticvar array $truncate_paths Array of paths to truncate. + * * @param string $ignore_class Optional. A class to ignore all function calls within - useful * when you want to just give info about the callee. Default null. * @param int $skip_frames Optional. A number of stack frames to skip - useful for unwinding @@ -5376,6 +5378,8 @@ function wp_allowed_protocols() { * of individual calls. */ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) { + static $truncate_paths; + if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) { $trace = debug_backtrace( false ); } else { @@ -5386,6 +5390,13 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr $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--; @@ -5399,7 +5410,7 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr 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] ) . "')"; + $caller[] = $call['function'] . "('" . str_replace( $truncate_paths, '', wp_normalize_path( $call['args'][0] ) ) . "')"; } else { $caller[] = $call['function']; }