From 7c8acf712e46fa3df8d83514be3d67e9b7635455 Mon Sep 17 00:00:00 2001 From: Andrew Winter Date: Fri, 12 Apr 2013 10:57:33 +0900 Subject: [PATCH] Prevent extensions from clobbering all globals. --- lib/Twig/Environment.php | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index ff089c2..32b026a 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -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()); -- 1.7.2.5