From 4df8e9d5958e3d3415a15a9d92763aa2cd6ab940 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Thu, 15 Dec 2011 07:17:29 +0000 Subject: [PATCH] Throw an exception if Parser::disableCache is called before mOutput initialized (Aka when not parsing something). So far I've encountered 2 extensions that give fatal errors from calling $wgParser->disableOutput() from hooks that are called at points where parsing is not taking place! Exception with a backtrace is much nicer than "Fatal error: Call to a member function disableCache() on a non-object..." --- includes/parser/Parser.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index ca02d6b756..3c3d59d4f4 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -5122,6 +5122,10 @@ class Parser { */ function disableCache() { wfDebug( "Parser output marked as uncacheable.\n" ); + if ( !$this->mOutput ) { + throw new MWException( __METHOD__ . + " can only be called when actually parsing something" ); + } $this->mOutput->setCacheTime( -1 ); // old style, for compatibility $this->mOutput->updateCacheExpiry( 0 ); // new style, for consistency } -- 2.20.1