mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-27 10:41:10 +00:00
0ef96f6b1d
Commits -------5b91f12Update testsa5ef326Use Template->getContext in non-strict mode too Discussion ---------- Use Template->getContext() when in non-strict mode, too As described in #380 using the current `isset($context['test']) ? $context['test'] : null` approach can cause problems in some cases: The ternary operator always returns by value and thus PHP's copy-on-write concept does not apply. So `$context['test']` needs to be copied in any case, even though a write never happens to it. Basically Twig is copying the values of all variables ever used inside Twig if it operates in non-strict mode. This is problematic when `$context['test']` contains big arrays as the whole array is copied. In this patch I change Twig to use `Template->getContext` when in non-strict mode too and add an `isStrictVariables` check in there.