mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CiteThisPage
synced 2024-11-13 18:27:06 +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;
|
$wgAllowCiteGroups = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An emergency optimisation measure for caching cite <references /> output.
|
||||||
|
*/
|
||||||
|
$wgCiteCacheReferences = false;
|
||||||
|
|
||||||
function wfCite() {
|
function wfCite() {
|
||||||
new Cite;
|
new Cite;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -367,18 +367,24 @@ class Cite {
|
||||||
$cacheKey = wfMemcKey( 'citeref', md5($parserInput), $this->mParser->Title()->getArticleID() );
|
$cacheKey = wfMemcKey( 'citeref', md5($parserInput), $this->mParser->Title()->getArticleID() );
|
||||||
|
|
||||||
wfProfileOut( __METHOD__ .'-entries' );
|
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' );
|
wfProfileIn( __METHOD__ .'-parse' );
|
||||||
|
|
||||||
// Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
|
// Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
|
||||||
$ret = rtrim( $this->parse( $parserInput ), "\n" );
|
$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' );
|
wfProfileOut( __METHOD__ .'-parse' );
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue