resourceloader: Migrate from msg_resource table to object cache
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 13 Nov 2015 00:04:12 +0000 (00:04 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 8 Dec 2015 14:02:38 +0000 (14:02 +0000)
commit5d5b269e0e63641f3dacd663d8a39f376a905434
treefc62578036f69c9d6c2504fb526ea5d59edd0638
parentc655e38f75898463ef0a70d79abfa83b84b83852
resourceloader: Migrate from msg_resource table to object cache

MessageBlobStore class:
* Make logger aware.
* Log an error if json encoding fails.
* Stop using the DB table. WANObjectCache supports everything we need:
  - Batch retrieval.
  - Invalidate keys with wildcard selects or cascading check keys.
* Update tests slightly since the actual update now happens on-demand as
  part of get() instead of within updateMessage().

ResourceLoader class:
* Remove all interaction with the msg_resource table. Remove db table later.
* Refactor code to use a hash of the blob instead of a timestamp.
  Timestamps are unreliable and roll over too frequently for message blob store
  because there is no authoritative source. The timestamps were inferred based on
  when a change is observed. Message overrides from the local wiki have an
  explicit update event when the page is edited. All other messages, such as
  from MediaWiki core and extensions using LocalisationCache, have a single
  timestamp for all messages which rolls over every time the cache is rebuilt.
  A hash is deterministic, and won't cause needless invalidation (T102578).
* Remove redundant pre-fetching in makeModuleResponse().
  This is already done by preloadModuleInfo() in respond().
* Don't bother storing and retreiving empty "{}" objects.
  Instead, detect whether a module's message list is empty at runtime.

ResourceLoaderModule class:
* Make logger aware.
* Log if a module's message blob was not preloaded.

cleanupRemovedModules:
* Now that blobs have a TTL, there's no need to prune old entries.

Bug: T113092
Bug: T92357
Change-Id: Id8c26f41a82597e34013f95294cdc3971a4f52ae
includes/cache/MessageBlobStore.php
includes/cache/MessageCache.php
includes/libs/objectcache/WANObjectCache.php
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderModule.php
maintenance/cleanupRemovedModules.php
tests/phpunit/includes/OutputPageTest.php
tests/phpunit/includes/resourceloader/MessageBlobStoreTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php