r68110 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68109‎ | r68110 | r68111 >
Date:00:26, 16 June 2010
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
In wfGetAllCallers(): Added a limit to the stack depth, omit wfGetAllCallers itself from the list, added articles to the documentation.
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2878,11 +2878,19 @@
28792879 }
28802880
28812881 /**
2882 - * Return a string consisting all callers in stack, somewhat useful sometimes
2883 - * for profiling specific points
 2882+ * Return a string consisting of callers in the stack. Useful sometimes
 2883+ * for profiling specific points.
 2884+ *
 2885+ * @param $limit The maximum depth of the stack frame to return, or false for
 2886+ * the entire stack.
28842887 */
2885 -function wfGetAllCallers() {
2886 - return implode('/', array_map('wfFormatStackFrame',array_reverse(wfDebugBacktrace())));
 2888+function wfGetAllCallers( $limit = 3 ) {
 2889+ $trace = array_reverse( wfDebugBacktrace() );
 2890+ if ( !$limit || $limit > count( $trace ) - 1 ) {
 2891+ $limit = count( $trace ) - 1;
 2892+ }
 2893+ $trace = array_slice( $trace, -$limit - 1, $limit );
 2894+ return implode( '/', array_map( 'wfFormatStackFrame', $trace ) );
28872895 }
28882896
28892897 /**

Comments

#Comment by Midom (talk | contribs)   12:06, 25 June 2010

Thanks for articles :-)

Though I'm not sure I like the new default :)

Status & tagging log