From 1b3f9bf3211d5822da559dbe2ee148a60840cfb1 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 16 Jun 2010 00:26:20 +0000 Subject: [PATCH] In wfGetAllCallers(): Added a limit to the stack depth, omit wfGetAllCallers itself from the list, added articles to the documentation. --- includes/GlobalFunctions.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 76d67f9567..a7d6cc2083 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2878,11 +2878,19 @@ function wfGetCaller( $level = 2 ) { } /** - * Return a string consisting all callers in stack, somewhat useful sometimes - * for profiling specific points + * Return a string consisting of callers in the stack. Useful sometimes + * for profiling specific points. + * + * @param $limit The maximum depth of the stack frame to return, or false for + * the entire stack. */ -function wfGetAllCallers() { - return implode('/', array_map('wfFormatStackFrame',array_reverse(wfDebugBacktrace()))); +function wfGetAllCallers( $limit = 3 ) { + $trace = array_reverse( wfDebugBacktrace() ); + if ( !$limit || $limit > count( $trace ) - 1 ) { + $limit = count( $trace ) - 1; + } + $trace = array_slice( $trace, -$limit - 1, $limit ); + return implode( '/', array_map( 'wfFormatStackFrame', $trace ) ); } /** -- 2.20.1