resourceloader: Refactor ResourceLoaderWikiModule to reduce database queries
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 4 Jun 2015 01:52:42 +0000 (02:52 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 4 Jun 2015 23:43:46 +0000 (00:43 +0100)
commit6b2a7fd4b1149bf78ae17d6035c87de847d75cce
tree99ac68c485c9376159cc90f6f30f205bf53a170c
parent5d0a9bb42d34e399ab7607abd7945e88c21727f7
resourceloader: Refactor ResourceLoaderWikiModule to reduce database queries

Wiki modules are special due to their isKnownEmpty implementation and support
for foreign databases. MediaWiki doesn't have convenient ways of making
Revision objects for remote wikis. As such, wiki modules will keep using meta
data to generate the hash.

However minimise needless cache invalidation by refining the implementation.

Impact:
* Remove use of getMsgBlobMtime(). This module doesn't support getMessages().
* In the title info, use the revision content sha1 and size for tracking.
  The page_touched previously used updates too often. It's updated both on edits
  for various types of purges. Using the rev_sha1 means old versions return
  when the content is the same. Regardless of how the content changed via
  revert or actual edits resulting in the same contnet.
* Change in-process cache to be keyed by page list instead of entire
  ResourceLoaderContext.
  Because of this, getTitleInfo() was previously performing its batch query
  twice on the same page. Once for only=styles (top) and only=scripts (bottom).
  Both operate on the full getPages() set but had different context keys.

Clean up:
* Better document the support for foreign databases.
* Move Title construction to getContent to reduce duplication.
* Remove use of getDefinitionMtime(). That method is a no-op since the switch
  to version hashing.
* Remove remaining use of mtime in getModifiedTime(). This is now covered by
  hashing the title info in getDefinitionSummary().

Also refactor the code to be more readable. No intended change in behaviour.

Bug: T98087
Change-Id: Id46740db04c0c42bc5ca87d1487230a32feb34df
includes/resourceloader/ResourceLoaderWikiModule.php
tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php