From: Timo Tijhof Date: Wed, 4 Dec 2013 00:26:16 +0000 (+0100) Subject: resourceloader: Make sure hashmtime cache key is different by language X-Git-Tag: 1.31.0-rc.0~17801^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=044713c4dc089d956ac0894d54d41406ccc3be15;p=lhc%2Fweb%2Fwiklou.git resourceloader: Make sure hashmtime cache key is different by language We were continuously invalidating the cache for the ResourceLoaderLanguageDataModule every time a request for a langauge other than the previous request came in as they all resulted in the same cache key. This could be resolved by adding $context->getLang() to the key (which would be enough for langdata module, but not enough for other uses of hashmtime), or by adding $context->getHash() (which will fragment it for all possible context factor combinations, slightly overkill for most cases, but would work). Instead resolving it the same way we did in d3bdda3 for a similar issue in #getDefinitionMtime: by adding the hash itself to the key. That way it will solve the problem, including two nice things: * Not fragment anymore than necessary (if it doesn't vary by skin, it won't vary by skin, and same for language etc.). * Always separate keys when the value is different (if something can very based on other factors, e.g. LocalSettings globals or whatever untracked method may exist for influencing anything, it will all work as expected). * Don't keep alternating and incrementing the timestamp while a multi-server infrastructure is syncing code (e.g. old code and new code for the same request context will not result in the same key and each old/new server alternatingly increasing the timestamp, instead the first new server will make the new key and the other servers will gradually start finding the new key with the timestamp of when it was first seen). Change-Id: Ifa9088c11c388ca6c912e62efc43494e91702603 --- diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index db84dcf0d9..429bcecdf7 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -408,7 +408,7 @@ abstract class ResourceLoaderModule { } $cache = wfGetCache( CACHE_ANYTHING ); - $key = wfMemcKey( 'resourceloader', 'modulemodifiedhash', $this->getName() ); + $key = wfMemcKey( 'resourceloader', 'modulemodifiedhash', $this->getName(), $hash ); $data = $cache->get( $key ); if ( is_array( $data ) && $data['hash'] === $hash ) {