Legoktm has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/347139 )

Change subject: Make sure cache key always goes through makeKey*()
......................................................................

Make sure cache key always goes through makeKey*()

To protect against invalid memcache keys being created, use the
makeKey() and makeGlobalKey() functions that are part of ObjectCache
instead of blindly using sha1() on something that has the potential to
be invalid.

Bug: T159783
Change-Id: I43182de99aab370fe1e0ba23623ca2a786f77d5c
---
M includes/JCCache.php
1 file changed, 7 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/JsonConfig 
refs/changes/39/347139/1

diff --git a/includes/JCCache.php b/includes/JCCache.php
index fc396ee..c023339 100644
--- a/includes/JCCache.php
+++ b/includes/JCCache.php
@@ -28,20 +28,21 @@
                $this->titleValue = $titleValue;
                $conf = $this->titleValue->getConfig();
                $flRev = $conf->flaggedRevs;
-               $key = implode( ':', [
+               $this->cache = wfGetCache( CACHE_ANYTHING );
+               $keyArgs = [
                        'JsonConfig',
                        $wgJsonConfigCacheKeyPrefix,
                        $conf->cacheKey,
                        ( $flRev === null ? '' : ( $flRev ? 'T' : 'F' ) ),
                        $titleValue->getNamespace(),
-                       sha1( $titleValue->getDBkey() ),
-               ] );
+                       $titleValue->getDBkey(),
+               ];
                if ( $conf->isLocal ) {
-                       $key = wfMemcKey( $key );
+                       $this->key = call_user_func( [ $this->cache, 'makeKey' 
], $keyArgs );
+               } else {
+                       $this->key = call_user_func( [ $this->cache, 
'makeGlobalKey' ], $keyArgs );
                }
                $this->cacheExpiration = $conf->cacheExp;
-               $this->key = $key;
-               $this->cache = wfGetCache( CACHE_ANYTHING );
                $this->content = $content ?: null ; // ensure that if we don't 
have content, we use 'null'
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/347139
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I43182de99aab370fe1e0ba23623ca2a786f77d5c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/JsonConfig
Gerrit-Branch: master
Gerrit-Owner: Legoktm <lego...@member.fsf.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to