jenkins-bot has submitted this change and it was merged.
Change subject: Put get diff body cache key into own function
......................................................................
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
---
M includes/diff/DifferenceEngine.php
1 file changed, 18 insertions(+), 2 deletions(-)
Approvals:
IAlex: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/diff/DifferenceEngine.php
b/includes/diff/DifferenceEngine.php
index ea74164..0dd9af0 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -654,8 +654,8 @@
// 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 );
@@ -696,6 +696,22 @@
}
/**
+ * 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.
*
* This implementation uses generateTextDiffBody() to generate a diff
based on the default
--
To view, visit https://gerrit.wikimedia.org/r/92167
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I22bf4e70f86da832a86baf6790ad4a403fce4bf1
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: IAlex <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits