mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CiteThisPage
synced 2024-11-12 01:14:26 +00:00
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.
This commit is contained in:
parent
813c686a03
commit
43a4822175
5
Cite.php
5
Cite.php
|
@ -45,6 +45,11 @@ define( 'CITE_DEFAULT_GROUP', '');
|
|||
*/
|
||||
$wgAllowCiteGroups = true;
|
||||
|
||||
/**
|
||||
* An emergency optimisation measure for caching cite <references /> output.
|
||||
*/
|
||||
$wgCiteCacheReferences = false;
|
||||
|
||||
function wfCite() {
|
||||
new Cite;
|
||||
return true;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue