Add an extra option for extensions adding an extra key directly instead of the hook...
authorPlatonides <platonides@users.mediawiki.org>
Tue, 10 Aug 2010 14:38:14 +0000 (14:38 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Tue, 10 Aug 2010 14:38:14 +0000 (14:38 +0000)
includes/parser/ParserOptions.php

index 72e4242..bdff54c 100644 (file)
@@ -38,6 +38,7 @@ class ParserOptions {
        var $mIsSectionPreview;          # Parsing the page for a "preview" operation on a single section
        var $mIsPrintable;               # Parsing the printable version of the page
        
+       var $mExtraKey = '';             # Extra key that should be present in the caching key.
        
        protected $accessedOptions;
        
@@ -133,6 +134,13 @@ class ParserOptions {
        function setIsSectionPreview( $x )          { return wfSetVar( $this->mIsSectionPreview, $x ); }
        function setIsPrintable( $x )               { return wfSetVar( $this->mIsPrintable, $x ); }
 
+       /**
+        * Extra key that should be present in the parser cache key.
+        */
+       function addExtraKey( $key ) {
+               $this->mExtraKey .= '!' . $key;
+       }
+
        function __construct( $user = null ) {
                $this->initialiseFromUser( $user );
        }
@@ -299,6 +307,9 @@ class ParserOptions {
                if (  $this->mIsPrintable && in_array( 'printable', $forOptions ) )
                        $confstr .= '!printable=1';
                
+               if ( $this->mExtraKey != '' )
+                       $confstr .= $this->mExtraKey;
+               
                // Give a chance for extensions to modify the hash, if they have
                // extra options or other effects on the parser cache.
                wfRunHooks( 'PageRenderingHash', array( &$confstr ) );