https://www.mediawiki.org/wiki/Special:Code/MediaWiki/106310

Revision: 106310
Author:   bawolff
Date:     2011-12-15 07:17:29 +0000 (Thu, 15 Dec 2011)
Log Message:
-----------
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..."

Modified Paths:
--------------
    trunk/phase3/includes/parser/Parser.php

Modified: trunk/phase3/includes/parser/Parser.php
===================================================================
--- trunk/phase3/includes/parser/Parser.php     2011-12-15 02:37:35 UTC (rev 
106309)
+++ trunk/phase3/includes/parser/Parser.php     2011-12-15 07:17:29 UTC (rev 
106310)
@@ -5122,6 +5122,10 @@
         */
        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
        }


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

Reply via email to