Prevent extensions from clobbering all globals.
authorAndrew Winter <awinter@sbstrm.co.jp>
Fri, 12 Apr 2013 01:57:33 +0000 (10:57 +0900)
committerFabien Potencier <fabien.potencier@gmail.com>
Fri, 12 Apr 2013 09:46:40 +0000 (11:46 +0200)
lib/Twig/Environment.php

index ff089c2..32b026a 100644 (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());