Fixes to r62995:
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Fri, 26 Feb 2010 08:53:06 +0000 (08:53 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Fri, 26 Feb 2010 08:53:06 +0000 (08:53 +0000)
* Avoid fatal error if $wgProfiler is either not a object (ProfilerStub.php) or an instance of Profiler
* Set $wgProfiler to null in ProfilerStub.php so that $wgProfiler doesn't need to be checked with "isset" first, updated check in GlobalFunctions.php accordingly

includes/GlobalFunctions.php
includes/Profiler.php
includes/ProfilerSimple.php
includes/ProfilerStub.php
includes/SkinTemplate.php

index 0bf19ad..5d339fc 100644 (file)
@@ -496,7 +496,7 @@ function wfLogProfilingData() {
        global $wgRequestTime, $wgDebugLogFile, $wgDebugRawPage, $wgRequest;
        global $wgProfiler, $wgProfileLimit, $wgUser;
        # Profiling must actually be enabled...
-       if( !isset( $wgProfiler ) ) return;
+       if( !is_null( $wgProfiler ) ) return;
        # Get total page request time
        $now = wfTime();
        $elapsed = $now - $wgRequestTime;
index 817b71a..f91fcf9 100644 (file)
@@ -61,6 +61,7 @@ if (!function_exists('memory_get_usage')) {
 class Profiler {
        var $mStack = array (), $mWorkStack = array (), $mCollated = array ();
        var $mCalls = array (), $mTotals = array ();
+       var $mTemplated = false;
 
        function __construct() {
                // Push an entry for the pre-profile setup time onto the stack
@@ -139,6 +140,14 @@ class Profiler {
                }
        }
 
+       /**
+        * Mark this call as templated or not
+        * @param $t Boolean
+        */
+       function setTemplated( $t ) {
+               $this->mTemplated = $t;
+       }
+
        /**
         * called by wfGetProfilingOutput()
         */
index 5d2a775..5989061 100644 (file)
@@ -16,7 +16,6 @@ if ( !class_exists( 'Profiler' ) ) {
 class ProfilerSimple extends Profiler {
        var $mMinimumTime = 0;
        var $mProfileID = false;
-       var $mTemplated = false;
 
        function __construct() {
                global $wgRequestTime, $wgRUstart;
@@ -55,14 +54,6 @@ class ProfilerSimple extends Profiler {
                }
        }
 
-       /**
-        * Mark this call as templated or not
-        * @param boolean $t
-        */
-       function setTemplated( $t ) {
-               $this->mTemplated = $t;
-       }
-
        function profileIn($functionname) {
                global $wgDebugFunctionEntry;
                if ($wgDebugFunctionEntry) {
index 100cb8d..575fa7e 100644 (file)
@@ -7,6 +7,7 @@
 
 /** backward compatibility */
 $wgProfiling = false;
+$wgProfiler = null;
 
 /** is setproctitle function available ? */
 $haveProctitle = function_exists( 'setproctitle' );
index 365fa68..9b4a287 100644 (file)
@@ -137,7 +137,9 @@ class SkinTemplate extends Skin {
                global $wgArticlePath, $wgScriptPath, $wgServer, $wgProfiler;
 
                wfProfileIn( __METHOD__ );
-               $wgProfiler->setTemplated(true);
+               if ( is_object( $wgProfiler ) ) {
+                       $wgProfiler->setTemplated( true );
+               }
 
                $oldid = $wgRequest->getVal( 'oldid' );
                $diff = $wgRequest->getVal( 'diff' );