Adding ignoreStrictCheck option for call_user_func_array, if throwing exception

This commit is contained in:
Barta Tamás
2013-10-16 22:49:43 +02:00
committed by Fabien Potencier
parent c9eca3508c
commit c711d37f1d
+10 -1
View File
@@ -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