From 3f4b661ac337bdc9f26b75258f610a9b213e2b7b Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 10 Aug 2011 15:35:03 +0000 Subject: [PATCH] Various profiler tweaks: * Add some debugging output to bad profiler config * Make member variables all protected, nothing uses them outside of Profiler and its subclasses * Allow setting $mProfilerID from the config --- includes/profiler/Profiler.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php index 2b5709653a..8283226ae6 100644 --- a/includes/profiler/Profiler.php +++ b/includes/profiler/Profiler.php @@ -34,12 +34,10 @@ function wfProfileOut( $functionname = 'missing' ) { * @todo document */ class Profiler { - var $mStack = array (), $mWorkStack = array (), $mCollated = array (); - var $mCalls = array (), $mTotals = array (); - var $mTemplated = false; - var $mTimeMetric = 'wall'; - private $mCollateDone = false; - protected $mProfileID = false; + protected $mStack = array(), $mWorkStack = array (), $mCollated = array (), + $mCalls = array (), $mTotals = array (); + protected $mTimeMetric = 'wall'; + protected $mProfileID = false, $mCollateDone = false, $mTemplated = false; private static $__instance = null; function __construct( $params ) { @@ -54,6 +52,9 @@ class Profiler { if ( isset( $params['timeMetric'] ) ) { $this->mTimeMetric = $params['timeMetric']; } + if ( isset( $params['profileID'] ) ) { + $this->mProfileID = $params['profileID']; + } } /** @@ -64,11 +65,19 @@ class Profiler { if( is_null( self::$__instance ) ) { global $wgProfiler; if( is_array( $wgProfiler ) ) { - $class = isset( $wgProfiler['class'] ) ? $wgProfiler['class'] : 'ProfilerStub'; + if( !isset( $wgProfiler['class'] ) ) { + wfDebug( __METHOD__ . " called without \$wgProfiler['class']" + . ' set, falling back to ProfilerStub for safety' ); + $class = 'ProfilerStub'; + } else { + $class = $wgProfiler['class']; + } self::$__instance = new $class( $wgProfiler ); } elseif( $wgProfiler instanceof Profiler ) { self::$__instance = $wgProfiler; // back-compat } else { + wfDebug( __METHOD__ . ' called without bogus $wgProfiler setting,' + . ' falling back to ProfilerStub for safety' ); self::$__instance = new ProfilerStub( $wgProfiler ); } } -- 2.20.1