From c711d37f1d6a5ee9ec9923bd76a47f0034113468 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Barta=20Tam=C3=A1s?= Date: Wed, 16 Oct 2013 22:49:43 +0200 Subject: [PATCH] Adding ignoreStrictCheck option for call_user_func_array, if throwing exception --- lib/Twig/Template.php | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index d1e281d..8573d34 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -446,7 +446,16 @@ abstract class Twig_Template implements Twig_TemplateInterface $this->env->getExtension('sandbox')->checkMethodAllowed($object, $method); } - $ret = call_user_func_array(array($object, $method), $arguments); + // Some objects throw exceptions when they have __call, and the method we try + // to call is not supported. If ignoreStrictCheck is true, we should return null. + try { + $ret = call_user_func_array(array($object, $method), $arguments); + } catch (\BadMethodCallException $e) { + if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { + return null; + } + throw $e; + } // useful when calling a template method from a template // this is not supported but unfortunately heavily used in the Symfony profiler -- 1.7.2.5