From a8078e868cda34c855d1bb18536140023a3c94e0 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 12 Jul 2013 22:48:11 +0200 Subject: [PATCH] Allowing infinite sandboxes within TemplateEngine --- .../system/template/TemplateEngine.class.php | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php index 42cc5ac252..611125bb86 100755 --- a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php +++ b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php @@ -84,9 +84,9 @@ class TemplateEngine extends SingletonFactory { /** * all cached variables for usage after execution in sandbox - * @var array + * @var array */ - protected $sandboxVars = null; + protected $sandboxVars = array(); /** * contains all templates with assigned template listeners. @@ -504,25 +504,19 @@ class TemplateEngine extends SingletonFactory { * Enables execution in sandbox. */ public function enableSandbox() { - if ($this->sandboxVars === null) { - $this->sandboxVars = $this->v; - } - else { - throw new SystemException('TemplateEngine is already in sandbox mode. Disable the current sandbox mode before you enable a new one.'); - } + $index = count($this->sandboxVars); + $this->sandboxVars[$index] = $this->v; } /** * Disables execution in sandbox. */ public function disableSandbox() { - if ($this->sandboxVars !== null) { - $this->v = $this->sandboxVars; - $this->sandboxVars = null; - } - else { - throw new SystemException('TemplateEngine is not in sandbox mode at the moment.'); + if (empty($this->sandboxVars)) { + throw new SystemException('TemplateEngine is currently not running in a sandbox.'); } + + $this->v = array_pop($this->sandboxVars); } /** -- 2.20.1