diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index a510a398..0747aa03 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -335,6 +335,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase */ public function getRenderedTemplateCode() { + $level = ob_get_level(); try { ob_start(); if (empty($this->properties['unifunc']) || !is_callable($this->properties['unifunc'])) { @@ -359,7 +360,9 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase return ob_get_clean(); } catch (Exception $e) { - ob_get_clean(); + while (ob_get_level() > $level) { + ob_end_clean(); + } throw $e; } } diff --git a/libs/sysplugins/smarty_resource_uncompiled.php b/libs/sysplugins/smarty_resource_uncompiled.php index 26a9a57c..a52d86e8 100644 --- a/libs/sysplugins/smarty_resource_uncompiled.php +++ b/libs/sysplugins/smarty_resource_uncompiled.php @@ -56,13 +56,16 @@ abstract class Smarty_Resource_Uncompiled extends Smarty_Resource */ public function render($_template) { + $level = ob_get_level(); + ob_start(); try { - ob_start(); $this->renderUncompiled($_template->source, $_template); return ob_get_clean(); } catch (Exception $e) { - ob_get_clean(); + while (ob_get_level() > $level) { + ob_end_clean(); + } throw $e; } } diff --git a/libs/sysplugins/smarty_template_compiled.php b/libs/sysplugins/smarty_template_compiled.php index 3a3cbd3b..22d9418f 100644 --- a/libs/sysplugins/smarty_template_compiled.php +++ b/libs/sysplugins/smarty_template_compiled.php @@ -149,12 +149,15 @@ class Smarty_Template_Compiled $compileCheck = $_template->smarty->compile_check; $_template->smarty->compile_check = false; if ($_template->source->recompiled) { + $level = ob_get_level(); + ob_start(); try { - ob_start(); eval("?>" . $this->code); } catch (Exception $e) { - ob_get_clean(); + while (ob_get_level() > $level) { + ob_end_clean(); + } throw $e; } ob_get_clean(); diff --git a/libs/sysplugins/smarty_template_source.php b/libs/sysplugins/smarty_template_source.php index 85d31315..dd537f0e 100644 --- a/libs/sysplugins/smarty_template_source.php +++ b/libs/sysplugins/smarty_template_source.php @@ -219,13 +219,16 @@ class Smarty_Template_Source */ public function renderUncompiled(Smarty_Internal_Template $_template) { + $level = ob_get_level(); + ob_start(); try { - ob_start(); $this->handler->renderUncompiled($_template->source, $_template); return ob_get_clean(); } catch (Exception $e) { - ob_get_clean(); + while (ob_get_level() > $level) { + ob_end_clean(); + } throw $e; } }