resourceloader: Add definition hashing to improve cache invalidation
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 18 Oct 2013 13:34:50 +0000 (15:34 +0200)
committerOri Livneh <ori@wikimedia.org>
Tue, 3 Dec 2013 05:45:33 +0000 (21:45 -0800)
commitd3bdda32211425d2ecd2deb8eee5101dc068ee25
treeb4207940dc991ce39db5e26c3069b9f83d3a0fa3
parentca9a6a4ff3af87a7666005c436dc2bb5d62506b0
resourceloader: Add definition hashing to improve cache invalidation

Currently we invalidate module caches based on timestamps from
various places (including message blob, file mtimes and more).

This meant that when a module changes such that the maximum
detectable timestamp is still the same, the cache would not
invalidate.

Module classes can now implement a method to build a summary.
In most cases this should be (a normalised version of) the
definition array originally given to ResourceLoader::register
(such as $wgResourceModules items).

The most common scenarios this addresses:

* File lists (scripts, styles) being re-ordered.
* Files being removed when more recently changed files remain
  part of the module (e.g. removing an older file).
* Files or messages being added to a module while other more
  recently changed things are already part of the module.
  E.g. you create a message and use it in a js file, but forget
  to add the message to the module. Then later you add the msg
  key. This last update would be ignored, because the mtime of
  the message is no newer than the total which already included
  the (same) mtime of the js file added in the previous update.
* Change the concatenation order of pages in a Gadget definition.

Bug: 37812
Change-Id: I00cf086c981a84235623bf58fb83c9c23aa2d619
RELEASE-NOTES-1.23
includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderModule.php
includes/resourceloader/ResourceLoaderWikiModule.php
tests/phpunit/includes/ResourceLoaderModuleTest.php [new file with mode: 0644]