HomePhabricator

Use enableModuleContentVersion() for Wikibase\lib\SitesModule (take 2)

Description

Use enableModuleContentVersion() for Wikibase\lib\SitesModule (take 2)

This re-applies commit 6a7aa53dc944, reverting e1b60c7b1f065.

Original rationale:

Remove the need to maintain two separate code paths, one to
compute the script, and one to compute the module version hash.

Instead, let ResourceLoader do the module versioning based on the
content of the script. When setting enableModuleContentVersion(),
then module->getVersionHash() will call getScript() instead of
getDefinitionSummary().

Changes:

  • Remove now-redundant use of Memcached for the module hash. Add explicit use of Memcached via getWithSetCallback for the generated JavaScript code, which we don't want to recompute too often. This is effectively the same as before, except that it no longer applies only to the HTTP request for the 'startup' module. It now *also* applies to the HTTP request for the 'mw.config.values.wbSiteDetails' module itself. Previously it was actually computing both values, which kind of defeated the purpose of the cache. This happened because even on the main module request, we still need the version as well (for the E-Tag header).
  • Update the tests accordingly.

    For the Worker class testGetDefinitionSummary_caching becomes testGetSpecialSiteLinkGroups_caching.

    For the Module class, testGetDefinitionSummary was moved to it from the WorkerTest suite, as testGetVersionHash.

Difference from original attempt:

I orignally introduced the getWithSet caching call in
computeSiteDetails() which was a mistake, because that's for
each individual site object, not for the combined script of all
known MW sites. As such, it was caching the first iteration of
the for-loop, and then re-using it for all other sites.
Now, the caching is applied to the generated JavaScript code.

I've updated the test case to actually create a mock with
more than 1 site, so that this bug is exposed.
The original patch would have failed with this new test.

I also fixed another bug in the original code, which is that
it did not vary the cache by language code, despite the code
using that to make decisions.

Bug: T219549
Change-Id: I4e63853e352ed3d083590c4cf789de08468c4ba5

Details

Provenance
KrinkleAuthored on Mar 14 2019, 8:52 PM
Parents
rEWBAf3520cecebc6: Localisation updates from https://translatewiki.net.
Branches
Unknown
Tags
Unknown
ChangeId
I4e63853e352ed3d083590c4cf789de08468c4ba5