From b8b254da7fc478209dbf1d6bd9e5ee1e317ab435 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 26 Feb 2010 08:53:06 +0000 Subject: [PATCH] Fixes to r62995: * 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 | 2 +- includes/Profiler.php | 9 +++++++++ includes/ProfilerSimple.php | 9 --------- includes/ProfilerStub.php | 1 + includes/SkinTemplate.php | 4 +++- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 0bf19ad2ad..5d339fcd12 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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; diff --git a/includes/Profiler.php b/includes/Profiler.php index 817b71ab2c..f91fcf9d03 100644 --- a/includes/Profiler.php +++ b/includes/Profiler.php @@ -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() */ diff --git a/includes/ProfilerSimple.php b/includes/ProfilerSimple.php index 5d2a775ccc..5989061dcd 100644 --- a/includes/ProfilerSimple.php +++ b/includes/ProfilerSimple.php @@ -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) { diff --git a/includes/ProfilerStub.php b/includes/ProfilerStub.php index 100cb8df10..575fa7e8ef 100644 --- a/includes/ProfilerStub.php +++ b/includes/ProfilerStub.php @@ -7,6 +7,7 @@ /** backward compatibility */ $wgProfiling = false; +$wgProfiler = null; /** is setproctitle function available ? */ $haveProctitle = function_exists( 'setproctitle' ); diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 365fa6896a..9b4a287839 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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' ); -- 2.20.1