r70822 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70821‎ | r70822 | r70823 >
Date:14:38, 10 August 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Add an extra option for extensions adding an extra key directly instead of the hook or $wgRenderHashAppend, so that they can be added only to some instances.
Modified paths:
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -38,6 +38,7 @@
3939 var $mIsSectionPreview; # Parsing the page for a "preview" operation on a single section
4040 var $mIsPrintable; # Parsing the printable version of the page
4141
 42+ var $mExtraKey = ''; # Extra key that should be present in the caching key.
4243
4344 protected $accessedOptions;
4445
@@ -133,6 +134,13 @@
134135 function setIsSectionPreview( $x ) { return wfSetVar( $this->mIsSectionPreview, $x ); }
135136 function setIsPrintable( $x ) { return wfSetVar( $this->mIsPrintable, $x ); }
136137
 138+ /**
 139+ * Extra key that should be present in the parser cache key.
 140+ */
 141+ function addExtraKey( $key ) {
 142+ $this->mExtraKey .= '!' . $key;
 143+ }
 144+
137145 function __construct( $user = null ) {
138146 $this->initialiseFromUser( $user );
139147 }
@@ -299,6 +307,9 @@
300308 if ( $this->mIsPrintable && in_array( 'printable', $forOptions ) )
301309 $confstr .= '!printable=1';
302310
 311+ if ( $this->mExtraKey != '' )
 312+ $confstr .= $this->mExtraKey;
 313+
303314 // Give a chance for extensions to modify the hash, if they have
304315 // extra options or other effects on the parser cache.
305316 wfRunHooks( 'PageRenderingHash', array( &$confstr ) );

Follow-up revisions

RevisionCommit summaryAuthorDate
r70823Use ParserOptions instead of User for ParserCache interface....platonides14:52, 10 August 2010

Comments

#Comment by MarkAHershberger (talk | contribs)   00:48, 7 January 2011

This does get rid of (some of?) the need for special per-extension parserCache subclasses so I'm all for it!

#Comment by Platonides (talk | contribs)   19:55, 7 January 2011

Yes!

Status & tagging log