r94158 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94157‎ | r94158 | r94159 >
Date:15:35, 10 August 2011
Author:demon
Status:resolved (Comments)
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/includes/profiler/Profiler.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/profiler/Profiler.php
@@ -34,12 +34,10 @@
3535 * @todo document
3636 */
3737 class Profiler {
38 - var $mStack = array (), $mWorkStack = array (), $mCollated = array ();
39 - var $mCalls = array (), $mTotals = array ();
40 - var $mTemplated = false;
41 - var $mTimeMetric = 'wall';
42 - private $mCollateDone = false;
43 - protected $mProfileID = false;
 38+ protected $mStack = array(), $mWorkStack = array (), $mCollated = array (),
 39+ $mCalls = array (), $mTotals = array ();
 40+ protected $mTimeMetric = 'wall';
 41+ protected $mProfileID = false, $mCollateDone = false, $mTemplated = false;
4442 private static $__instance = null;
4543
4644 function __construct( $params ) {
@@ -54,6 +52,9 @@
5553 if ( isset( $params['timeMetric'] ) ) {
5654 $this->mTimeMetric = $params['timeMetric'];
5755 }
 56+ if ( isset( $params['profileID'] ) ) {
 57+ $this->mProfileID = $params['profileID'];
 58+ }
5859 }
5960
6061 /**
@@ -64,11 +65,19 @@
6566 if( is_null( self::$__instance ) ) {
6667 global $wgProfiler;
6768 if( is_array( $wgProfiler ) ) {
68 - $class = isset( $wgProfiler['class'] ) ? $wgProfiler['class'] : 'ProfilerStub';
 69+ if( !isset( $wgProfiler['class'] ) ) {
 70+ wfDebug( __METHOD__ . " called without \$wgProfiler['class']"
 71+ . ' set, falling back to ProfilerStub for safety' );
 72+ $class = 'ProfilerStub';
 73+ } else {
 74+ $class = $wgProfiler['class'];
 75+ }
6976 self::$__instance = new $class( $wgProfiler );
7077 } elseif( $wgProfiler instanceof Profiler ) {
7178 self::$__instance = $wgProfiler; // back-compat
7279 } else {
 80+ wfDebug( __METHOD__ . ' called without bogus $wgProfiler setting,'
 81+ . ' falling back to ProfilerStub for safety' );
7382 self::$__instance = new ProfilerStub( $wgProfiler );
7483 }
7584 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r95813Fixes for r94158: newlines and minor debugging typo (more silly fixmes)demon20:55, 30 August 2011

Comments

#Comment by Nikerabbit (talk | contribs)   07:29, 22 August 2011

Called without bogus setting? Missing newlines at the end.

Status & tagging log