Please sign in to comment.
merged branch nikic/optimizeVariableAccess2 (PR #382)
Commits ------- 5b91f12 Update tests a5ef326 Use 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.
- Loading branch information...
Showing with 25 additions and 21 deletions.