resourceloader: Add filename to validateScriptFile cache key
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 12 May 2017 18:05:20 +0000 (19:05 +0100)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 13 May 2017 00:24:40 +0000 (00:24 +0000)
* Add fileName to cache key to fix T52919. The cached parsed error
  message contains the filename, this should be part of the cache
  key as otherwise two identical user scripts may report the same
  error message, including " on line X of page Y" where Y is whichever
  of the two pages first created the cache entry.

* Make the cache key global instead of per-wiki. There is no need
  for this to be per-wiki.

Bug: T52919
Change-Id: I6c2718c53be7f6384a6486a4a8718ae7f423d216

includes/resourceloader/ResourceLoaderModule.php

index 97f9891..3ad6a84 100644 (file)
@@ -936,11 +936,12 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface {
                }
                $cache = ObjectCache::getMainWANInstance();
                return $cache->getWithSetCallback(
-                       $cache->makeKey(
+                       $cache->makeGlobalKey(
                                'resourceloader',
                                'jsparse',
                                self::$parseCacheVersion,
-                               md5( $contents )
+                               md5( $contents ),
+                               $fileName
                        ),
                        $cache::TTL_WEEK,
                        function () use ( $contents, $fileName ) {