r33924 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33923‎ | r33924 | r33925 >
Date:19:09, 26 April 2008
Author:ialex
Status:old
Tags:
Comment:
tweaks for r33917:
* use level 1 to get file and line, this from where the deprecated function was called
* added class if available
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2511,12 +2511,20 @@
25122512 * @return null
25132513 */
25142514 function wfDeprecated( $function ) {
2515 - $callers = debug_backtrace();
2516 - $file = @$callers[2]['file'];
2517 - $line = @$callers[2]['line'];
2518 - $func = @$callers[2]['function'];
2519 - if ( $func && $file ) {
2520 - trigger_error( "Use of $function is deprecated. Called from $func at $file:$line", E_USER_NOTICE );
 2515+ $callers = wfDebugBacktrace();
 2516+ if( isset( $callers[2] ) ){
 2517+ $callerfunc = $callers[2];
 2518+ $callerfile = $callers[1];
 2519+ if( isset( $callerfile['file'] ) && isset( $callerfile['line'] ) ){
 2520+ $file = $callerfile['file'] . ' at line ' . $callerfile['line'];
 2521+ } else {
 2522+ $file = '(internal function)';
 2523+ }
 2524+ $func = '';
 2525+ if( isset( $callerfunc['class'] ) )
 2526+ $func .= $callerfunc['class'] . '::';
 2527+ $func .= @$callerfunc['function'];
 2528+ trigger_error( "Use of $function is deprecated. Called from $func in $file", E_USER_NOTICE );
25212529 } else {
25222530 trigger_error( "Use of $function is deprecated.", E_USER_NOTICE );
25232531 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r33917* Print caller if possible in deprecated warningsnikerabbit17:57, 26 April 2008

Status & tagging log