http://www.mediawiki.org/wiki/Special:Code/MediaWiki/94158

Revision: 94158
Author:   demon
Date:     2011-08-10 15:35:03 +0000 (Wed, 10 Aug 2011)
Log Message:
-----------
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: trunk/phase3/includes/profiler/Profiler.php
===================================================================
--- trunk/phase3/includes/profiler/Profiler.php 2011-08-10 15:22:10 UTC (rev 
94157)
+++ trunk/phase3/includes/profiler/Profiler.php 2011-08-10 15:35:03 UTC (rev 
94158)
@@ -34,12 +34,10 @@
  * @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 @@
                if ( isset( $params['timeMetric'] ) ) {
                        $this->mTimeMetric = $params['timeMetric'];
                }
+               if ( isset( $params['profileID'] ) ) {
+                       $this->mProfileID = $params['profileID'];
+               }
        }
 
        /**
@@ -64,11 +65,19 @@
                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 );
                        }
                }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to