From: Barta Tamás Date: Wed, 16 Oct 2013 20:49:43 +0000 (+0200) Subject: Adding ignoreStrictCheck option for call_user_func_array, if throwing exception X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=c711d37f1d6a5ee9ec9923bd76a47f0034113468;p=web%2Fkonrad%2Ftwig.git Adding ignoreStrictCheck option for call_user_func_array, if throwing exception --- 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