From: aude Date: Sun, 27 Oct 2013 02:47:28 +0000 (+0000) Subject: Put get diff body cache key into own function X-Git-Tag: 1.31.0-rc.0~18334 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=607bcd6c63c0585c0706ffd5341d4c47f898e302;p=lhc%2Fweb%2Fwiklou.git Put get diff body cache key into own function This allows derivative DifferenceEngine classes to generate cache keys in a different format, as appropriate. (e.g. for Wikibase, allow diffs to be cached by language and fully localized) Bug: 55667 Change-Id: I22bf4e70f86da832a86baf6790ad4a403fce4bf1 --- diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index ea741641b4..0dd9af0844 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -654,8 +654,8 @@ class DifferenceEngine extends ContextSource { // Cacheable? $key = false; if ( $this->mOldid && $this->mNewid ) { - $key = wfMemcKey( 'diff', 'version', MW_DIFF_VERSION, - 'oldid', $this->mOldid, 'newid', $this->mNewid ); + $key = $this->getDiffBodyCacheKey(); + // Try cache if ( !$this->mRefreshCache ) { $difftext = $wgMemc->get( $key ); @@ -695,6 +695,22 @@ class DifferenceEngine extends ContextSource { return $difftext; } + /** + * Returns the cache key for diff body text or content. + * + * @return string + * @since 1.23 + * @throws MWException + */ + protected function getDiffBodyCacheKey() { + if ( !$this->mOldid || !$this->mNewid ) { + throw new MWException( 'mOldid and mNewid must be set to get diff cache key.' ); + } + + return wfMemcKey( 'diff', 'version', MW_DIFF_VERSION, + 'oldid', $this->mOldid, 'newid', $this->mNewid ); + } + /** * Generate a diff, no caching. *