r47190 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47189‎ | r47190 | r47191 >
Date:18:02, 12 February 2009
Author:werdna
Status:ok
Tags:
Comment:
Improve Cite references caching by making it dependent on a config setting, which defaults to off.
This way, we can still use it as emergency optimisation if the need arises.
Modified paths:
  • /trunk/extensions/Cite/Cite.php (modified) (history)
  • /trunk/extensions/Cite/Cite_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Cite/Cite_body.php
@@ -367,19 +367,25 @@
368368 $cacheKey = wfMemcKey( 'citeref', md5($parserInput), $this->mParser->Title()->getArticleID() );
369369
370370 wfProfileOut( __METHOD__ .'-entries' );
371 -
372 - wfProfileIn( __METHOD__.'-cache-get' );
373 - $data = $wgMemc->get( $cacheKey );
374 - wfProfileOut( __METHOD__.'-cache-get' );
375371
376 - if ( !$data ) {
 372+ global $wgCiteCacheReferences;
 373+ if ( $wgCiteCacheReferences ) {
 374+ wfProfileIn( __METHOD__.'-cache-get' );
 375+ $data = $wgMemc->get( $cacheKey );
 376+ wfProfileOut( __METHOD__.'-cache-get' );
 377+ }
 378+
 379+ if ( empty($data) ) {
377380 wfProfileIn( __METHOD__ .'-parse' );
378381
379382 // Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
380383 $ret = rtrim( $this->parse( $parserInput ), "\n" );
381 - $serData = $this->mParser->serialiseHalfParsedText( $ret );
382 - $wgMemc->set( $cacheKey, $serData, 86400 );
383384
 385+ if ( $wgCiteCacheReferences ) {
 386+ $serData = $this->mParser->serialiseHalfParsedText( $ret );
 387+ $wgMemc->set( $cacheKey, $serData, 86400 );
 388+ }
 389+
384390 wfProfileOut( __METHOD__ .'-parse' );
385391 } else {
386392 $ret = $this->mParser->unserialiseHalfParsedText( $data );
Index: trunk/extensions/Cite/Cite.php
@@ -45,6 +45,11 @@
4646 */
4747 $wgAllowCiteGroups = true;
4848
 49+/**
 50+ * An emergency optimisation measure for caching cite <references /> output.
 51+ */
 52+$wgCiteCacheReferences = false;
 53+
4954 function wfCite() {
5055 new Cite;
5156 return true;

Status & tagging log