From 8ad6638af8ab1bd6d729fdae3516306a9aaf1edc Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 25 May 2011 18:32:04 +0000 Subject: [PATCH] Moved wfGetCaller(), wfGetAllCallers() and wfFormatStackFrame() near other related functions --- includes/GlobalFunctions.php | 90 ++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a6c4f9f7fd..ceda004745 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1164,6 +1164,51 @@ function wfBacktrace() { return $msg; } +/** + * Get the name of the function which called this function + * + * @param $level Int + * @return Bool|string + */ +function wfGetCaller( $level = 2 ) { + $backtrace = wfDebugBacktrace(); + if ( isset( $backtrace[$level] ) ) { + return wfFormatStackFrame( $backtrace[$level] ); + } else { + $caller = 'unknown'; + } + return $caller; +} + +/** + * 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. + * @return String + */ +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 ) ); +} + +/** + * Return a string representation of frame + * + * @param $frame Array + * @return Bool + */ +function wfFormatStackFrame( $frame ) { + return isset( $frame['class'] ) ? + $frame['class'] . '::' . $frame['function'] : + $frame['function']; +} + /* Some generic result counters, pulled out of SearchEngine */ @@ -2995,51 +3040,6 @@ function wfGetPrecompiledData( $name ) { return false; } -/** - * Get the name of the function which called this function - * - * @param $level Int - * @return Bool|string - */ -function wfGetCaller( $level = 2 ) { - $backtrace = wfDebugBacktrace(); - if ( isset( $backtrace[$level] ) ) { - return wfFormatStackFrame( $backtrace[$level] ); - } else { - $caller = 'unknown'; - } - return $caller; -} - -/** - * 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. - * @return String - */ -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 ) ); -} - -/** - * Return a string representation of frame - * - * @param $frame Array - * @return Bool - */ -function wfFormatStackFrame( $frame ) { - return isset( $frame['class'] ) ? - $frame['class'] . '::' . $frame['function'] : - $frame['function']; -} - /** * Get a cache key * -- 2.20.1