r48227 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48226‎ | r48227 | r48228 >
Date:13:57, 9 March 2009
Author:ialex
Status:ok
Tags:
Comment:
Don't call debug_backtrace if it's disabled to avoid a lot of E_WARNING
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -879,18 +879,35 @@
880880 * murky circumstances, which may be triggered in part by stub objects
881881 * or other fancy talkin'.
882882 *
883 - * Will return an empty array if Zend Optimizer is detected, otherwise
884 - * the output from debug_backtrace() (trimmed).
 883+ * Will return an empty array if Zend Optimizer is detected or if
 884+ * debug_backtrace is disabled, otherwise the output from
 885+ * debug_backtrace() (trimmed).
885886 *
886887 * @return array of backtrace information
887888 */
888889 function wfDebugBacktrace() {
 890+ static $disabled = null;
 891+
889892 if( extension_loaded( 'Zend Optimizer' ) ) {
890893 wfDebug( "Zend Optimizer detected; skipping debug_backtrace for safety.\n" );
891894 return array();
892 - } else {
893 - return array_slice( debug_backtrace(), 1 );
894895 }
 896+
 897+ if ( is_null( $disabled ) ) {
 898+ $disabled = false;
 899+ $functions = explode( ',', ini_get( 'disable_functions' ) );
 900+ $functions = array_map( 'trim', $functions );
 901+ $functions = array_map( 'strtolower', $functions );
 902+ if ( in_array( 'debug_backtrace', $functions ) ) {
 903+ wfDebug( "debug_backtrace is in disabled_functions\n" );
 904+ $disabled = true;
 905+ }
 906+ }
 907+ if ( $disabled ) {
 908+ return array();
 909+ }
 910+
 911+ return array_slice( debug_backtrace(), 1 );
895912 }
896913
897914 function wfBacktrace() {

Status & tagging log