* 2.x:
Fix sandbox support when using include(template_from_string())
Add test to verify that filter is not working when template_from_string is used.
In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError
* 1.x:
Fix sandbox support when using include(template_from_string())
Add test to verify that filter is not working when template_from_string is used.
In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError
This PR was squashed before being merged into the 1.x branch.
Discussion
----------
In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError
If a template accidentally performs `|filter(...)` on a variable that isn't traversable (e.g. `null`), the calling code will encouter the raw `TypeError` that results from Twig trying to construct an `IteratorIterator` on that variable. This means that context information (e.g., in which exact template the error occurred, and on which line) is discarded, which makes it very difficult to debug your templates.
This commit adds code to throw a `RuntimeError` if Twig encounters a situation where there's no valid way to filter an array.
Commits
-------
567b1e2a In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
[3.x] Fix twig_compare w.r.t. whitespace trimming
Fixes#3352
Commits
-------
9d115f68 [3.x] Fix twig_compare w.r.t. whitespace trimming
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Fix twig_compare float-string trailing whitespace + refactor
Fixes#3345
Refs #2966 (and #3186)
(feel free to discard the "Factorize" commit if you favor performance over maintainability)
Commits
-------
d6822aeb Fix twig_compare float-string trailing whitespace + refactor
The new compilation implemented in Twig 3 for PHP 7 (to match the
comparison semantic of PHP 8) was missing the surrounding braces (which
are part of the AsbtractBinary compilation). This caused issues when the
full expression would involve other operators (like the not operator),
as things would then rely on having the correct precedence in PHP (which
would not be the case).