Aude has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/92167


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)

Change-Id: I22bf4e70f86da832a86baf6790ad4a403fce4bf1
---
M includes/diff/DifferenceEngine.php
1 file changed, 19 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/67/92167/1

diff --git a/includes/diff/DifferenceEngine.php 
b/includes/diff/DifferenceEngine.php
index e436f58..612ea06 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -202,6 +202,7 @@
        }
 
        function showDiffPage( $diffOnly = false ) {
+
                wfProfileIn( __METHOD__ );
 
                # Allow frames except in certain special cases
@@ -654,8 +655,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 +697,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: newchange
Gerrit-Change-Id: I22bf4e70f86da832a86baf6790ad4a403fce4bf1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to