r70823 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70822‎ | r70823 | r70824 >
Date:14:52, 10 August 2010
Author:platonides
Status:deferred
Tags:
Comment:
Use ParserOptions instead of User for ParserCache interface.
Do not save to parsercache if it is disabled.
Use addExtraKey() added in r70822 and remove now obsolete MV_ParserCache
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_Overlay.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_ParserCache.php (deleted) (history)
  • /trunk/extensions/MetavidWiki/includes/articlepages/MV_SequencePage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/includes/MV_ParserCache.php
@@ -1,34 +0,0 @@
2 -<?php
3 -/*
4 - * MV_ParserCache.php Created on Feb 27, 2008
5 - *
6 - * All Metavid Wiki code is Released under the GPL2
7 - * for more info visit http://metavid.org/wiki/Code
8 - *
9 - * @author Michael Dale
10 - * @email dale@ucsc.edu
11 - * @url http://metavid.org
12 - */
13 -if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
14 - // quick hack to shift namespace of inline metavid parse cache
15 - // avoids conflicts of inline display with full article display
16 - class MV_ParserCache extends ParserCache {
17 - var $extraKeyOpt = 'mv';
18 - var $addToKey = '';
19 - public static function & singleton() {
20 - static $instance;
21 - if ( !isset( $instance ) ) {
22 - global $parserMemc;
23 - $instance = new MV_ParserCache( $parserMemc );
24 - }
25 - // reset addToKey
26 - $instance->addToKey = '';
27 - return $instance;
28 - }
29 - function addToKey( $opt ) {
30 - $this->addToKey = $opt;
31 - }
32 - function getKey( &$article, &$user ) {
33 - return parent::getKey( $article, $user ) . $this->extraKeyOpt . $this->addToKey;
34 - }
35 - }
Index: trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php
@@ -139,7 +139,6 @@
140140 $wgAutoloadClasses['MV_StreamFile'] = dirname( __FILE__ ) . '/MV_StreamFile.php';
141141
142142 $wgAutoloadClasses['MV_StreamImage'] = dirname( __FILE__ ) . '/MV_StreamImage.php';
143 - $wgAutoloadClasses['MV_ParserCache'] = dirname( __FILE__ ) . '/MV_ParserCache.php';
144143 $wgAutoloadClasses['MV_MagicWords'] = dirname( __FILE__ ) . '/MV_MagicWords.php';
145144
146145 /**********************************************/
Index: trunk/extensions/MetavidWiki/includes/articlepages/MV_SequencePage.php
@@ -34,13 +34,16 @@
3535 //temporally stop cache:
3636 $wgEnableParserCache = $parserOutput =false;
3737
38 - if($wgEnableParserCache){
39 - $mvParserCache = & MV_ParserCache::singleton();
40 - $mvParserCache->addToKey( 'seq-xml' ); //differentiate the articles xml from article
41 - $parserOutput = $mvParserCache->get( $this, $wgUser );
 38+ if( $wgEnableParserCache ) {
 39+ $parserOptions = ParserOptions::newFromUser( $wgUser );
 40+ $mvParserCache = ParserCache::singleton();
 41+ $parserOptions->addExtraKey( 'mv:seq-xml' ); //differentiate the articles xml from article
 42+ $parserOutput = $mvParserCache->get( $this, $parserOptions );
 43+
 44+ if( $parserOutput != false )
 45+ return $parserOutput->getText();
4246 }
43 - if(isset($parserOutput) && $parserOutput != false)
44 - return $parserOutput->getText();
 47+
4548 //get the high level sequence description:
4649 $this->getSequenceHLRD();
4750 $this->parseHLRD_DOM();
Index: trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_Overlay.php
@@ -290,13 +290,16 @@
291291
292292 /*try to pull from cache: separate out cache for internal links vs external links cache*/
293293 if( $wgEnableParserCache ) {
294 - $MvParserCache = & MV_ParserCache::singleton();
295 - $add_opt = ( $absolute_links ) ? 'a':'';
296 - // add the dbKey since I don't know how to easy purge the cache and we are getting cache missmatch
297 - $add_opt .= $mvdTitle->getDBkey();
298 - $MvParserCache->addToKey( $add_opt );
 294+ $MvParserCache = ParserCache::singleton();
 295+ $popts = ParserOptions::newFromUser( $wgUser );
 296+ if ( $absolute_links ) {
 297+ $popts->addExtraKey( 'Metavid-absolutelinks' );
 298+ }
299299
300 - $parserOutput = $MvParserCache->get( $mvdArticle, $wgUser );
 300+ // FIXME: add the dbKey since I don't know how to easy purge the cache and we are getting cache missmatch
 301+ $popts->addExtraKey( $mvdTitle->getDBkey() );
 302+
 303+ $parserOutput = $MvParserCache->get( $mvdArticle, $popts );
301304 }else{
302305 $parserOutput=false;
303306 }
@@ -330,7 +333,9 @@
331334 }
332335 // output the page and save to cache
333336 $wgOut->addParserOutput( $parserOutput );
334 - $MvParserCache->save( $parserOutput, $mvdArticle, $wgUser );
 337+ if( $wgEnableParserCache ) {
 338+ $MvParserCache->save( $parserOutput, $mvdArticle, $popts );
 339+ }
335340 }
336341 }
337342 function parse_format_text( &$text, &$mvdTile, &$mvd_page = '', $absolute_links = false ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r78605Follow up r70823: store with the custom ParserOptions, too.platonides21:23, 19 December 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70822Add an extra option for extensions adding an extra key directly instead of th...platonides14:38, 10 August 2010

Status & tagging log