Prevent extensions from clobbering all globals.

This commit is contained in:
Andrew Winter
2013-04-12 10:57:33 +09:00
committed by Fabien Potencier
parent 1819d97520
commit 7c8acf712e
+6 -1
View File
@@ -1099,7 +1099,12 @@ class Twig_Environment
{
$globals = array();
foreach ($this->extensions as $extension) {
$globals = array_merge($globals, $extension->getGlobals());
$extGlob = $extension->getGlobals();
if (!is_array($extGlob)) {
throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension)));
}
$globals = array_merge($globals, $extGlob);
}
return array_merge($globals, $this->staging->getGlobals());