LightnCandy resolves recursively-defined partials twice, which leads to
the template file being hashed twice. While the cost of hashing the
partial the second time is minimised due to
FileContentsHasher::getFileContentsHash() caching the hash of a file in
APCu, it need not be paid.
Bug: T300210
Change-Id: Id3f62bf32c47f21181b1ec6d77a5ae9a703952b1
Ended up using
grep -Prl '\->setMethods\(' . | xargs sed -r -i 's/setMethods\(/onlyMethods\(/g'
special-casing setMethods( null ) -> onlyMethods( [] )
and then manual fix of failing test (from PS2 onwards).
Bug: T278010
Change-Id: I012dca7ae774bb430c1c44d50991ba0b633353f1
* There were two separate integration test suites, both testing
the TemplateParser class. One extended MediaWikiTestCase, which is an
alias for MediaWikiIntegrationTestCase. The other was extending
MediaWikiIntegrationTestCase directly.
I've merged these into the same file.
* Use an injected BagOStuff instance.
This means we can inject a mock and more cleanly assert the
subject class' observable behaviour and contract toward BagOStuff,
without hardcoding any internal details of TemplateParser.
* Add coverage for getTemplate() not using the cache in any way
when wgSecretKey is false.
Change-Id: Ic01f23b1d59c430ab6adf247e0244514b98e20b8
* Injecting the cache object makes the class easier to test.
* The $forceRecompile parameter was not used anywhere, not tested,
and only mentioned in one README (fixed in I13fba7314).
Based on past experience I generally expect that when bypassing a
cache, it is neither read from nor written to. Such feature might
be reached out to when testing something, in which case it should
not be stored.
If this was intended as a way to purge it in prod via eval.php,
we generally don't provide dedicated purging commands in code.
We either call BagOStuff or Memc/Apcu directly, or invalidate the
underlying data (e.g. touch the template file, or bump the cache
version).
To use TemplateParser without caching, one can still pass
'new EmptyBagOStuff' instead if needed.
* Set the $ttl parameter in the set() call.
It is generally an anti-pattern to store something without
any TTL as that means it can needlessly compete for space
even after further deployments have changed the key or stopped
using a particular key. For now I used a liberal default
of 1 week.
Change-Id: Ic84b996b46c72e9dc33eed2645204fc2d6c5240c
Template names aren't expected to be globally unique. Template paths are
by construction.
Include the template directory in the cache key in order to avoid the
cache keys of ambiguosly-named templates - e.g. index.mustache -
overriding one another.
Bug: T113095
Bug: T248010
Change-Id: I3196967ec2a7a5cec409a0c7ce4471a7d8773978