From 43a48221753564429c35809fa8b9ac6854e46629 Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Thu, 12 Feb 2009 18:02:27 +0000 Subject: [PATCH] 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. --- Cite.php | 5 +++++ Cite_body.php | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Cite.php b/Cite.php index c4c79fcd..158bb99f 100644 --- a/Cite.php +++ b/Cite.php @@ -45,6 +45,11 @@ define( 'CITE_DEFAULT_GROUP', ''); */ $wgAllowCiteGroups = true; +/** + * An emergency optimisation measure for caching cite output. + */ +$wgCiteCacheReferences = false; + function wfCite() { new Cite; return true; diff --git a/Cite_body.php b/Cite_body.php index 5b64a63c..b958b4dc 100644 --- a/Cite_body.php +++ b/Cite_body.php @@ -367,18 +367,24 @@ class Cite { $cacheKey = wfMemcKey( 'citeref', md5($parserInput), $this->mParser->Title()->getArticleID() ); wfProfileOut( __METHOD__ .'-entries' ); - - wfProfileIn( __METHOD__.'-cache-get' ); - $data = $wgMemc->get( $cacheKey ); - wfProfileOut( __METHOD__.'-cache-get' ); - if ( !$data ) { + global $wgCiteCacheReferences; + if ( $wgCiteCacheReferences ) { + wfProfileIn( __METHOD__.'-cache-get' ); + $data = $wgMemc->get( $cacheKey ); + wfProfileOut( __METHOD__.'-cache-get' ); + } + + if ( empty($data) ) { wfProfileIn( __METHOD__ .'-parse' ); // Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar $ret = rtrim( $this->parse( $parserInput ), "\n" ); - $serData = $this->mParser->serialiseHalfParsedText( $ret ); - $wgMemc->set( $cacheKey, $serData, 86400 ); + + if ( $wgCiteCacheReferences ) { + $serData = $this->mParser->serialiseHalfParsedText( $ret ); + $wgMemc->set( $cacheKey, $serData, 86400 ); + } wfProfileOut( __METHOD__ .'-parse' ); } else {