Commit graph

8 commits

Author SHA1 Message Date
Gergő Tisza
49350108bf Enable recursive partials in TemplateParser
Recursive partials are the only way to handle tree-like structures
such as nested lists. Allow setting FLAG_RUNTIMEPARTIAL in LightnCandy
so they can be used.

Since this has a slight performance impact (makes partial invocations
evaluation-time functions calls instead of compilation-time transclusions)
make it optional.

Change-Id: Ie37105a9f1ff92e1a79bfcd9f8578965e3d347f0
2017-09-10 05:51:07 +00:00
Brian Wolff
73e08353fb Better path traversal prevention in TemplateParser.
In practise this probably doesn't matter, since template names
are not user controlled, and php isn't stupid enough to fall for
tricks with nulls (afaict). Nonetheless, the code from Title is
only meant to prevent url traversal, it is not meant to prevent
file system path traversal.

Change-Id: Id690576326d03744acc8fbbe78f4b7a4b4c04d7e
2017-03-14 18:43:11 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Timo Tijhof
3b35719e74 tests: Remove unused $wgMemc resets
If we really need this we can do it in MediaWikiTestCase, next
to the setting of wgMainCacheType. But from what I can see the
code being tested here already doesn't use the old $wgMemc.

Change-Id: I9e4b2109b2f3c18d8d5551bbadae5711c1d4c0a6
2015-12-06 18:06:08 +00:00
S Page
c235e0717e Support mustache partials in server-side templates
This is sufficient to make https://gerrit.wikimedia.org/r/#/c/223165/
work.  It hardcodes .mustache as the extension, but so does
existing getTemplateFilename().

Bug: T97188
Change-Id: Id588ae9b43b13fcf35ebd285c826dd502ac424ec
2015-07-06 20:13:45 -07:00
Kunal Mehta
2f88829e1b TemplateParser: make most functions protected, only expose processTemplate()
All of the other functions expose internal implementation details, which no
external caller should ever need. In fact, no external caller does use these
functions directly.

The TemplateParser::compile() tests were removed as they're simply just
checking LightnCandy functionality, which is something the library should be
doing.

Change-Id: If9003d40315e0e5aa361c174b764b799e3b88c34
2015-03-22 20:31:59 -07:00
Timo Tijhof
cfcaa33fcc TemplateParser: Don't fatal on cache misses
Also add regression test, and coverage for more methods.

Was trying to eval the code which had the hmac integrity check in front of it,
which causes a syntax error in valid PHP code.

Follows-up db1866da4, 50c50bea2e.

Bug: T93436
Bug: T93511
Change-Id: Ie90074e4885de7340e53f59fdd479f5384b5eac6
2015-03-23 01:38:56 +00:00
kaldari
2ec0272218 Adding TemplateParser class providing interface to Mustache templates
The TemplateParser class provides a server-side interface to cachable
dynamically-compiled Mustache templates. It currently uses the
lightncandy library to do compilation (which is already included in
the vendor repo).

Also converting NoLocalSettings.php to use it as a proof-of-concept.

Bug: T379
Change-Id: I28cd13d4d1132bd386e2ae2f4f0d1dd88ad9162b
2015-02-19 17:41:45 -08:00