From 891495f84940ec4d91fbe9d7515c38ac6ba23fb6 Mon Sep 17 00:00:00 2001 From: uwetews Date: Sat, 24 Oct 2015 05:14:47 +0200 Subject: [PATCH] - improve recovery from ivalid compiled template code --- change_log.txt | 1 + libs/sysplugins/smarty_internal_testinstall.php | 6 +++--- libs/sysplugins/smarty_template_compiled.php | 14 ++++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/change_log.txt b/change_log.txt index cca26c83..c48df6c8 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,7 @@  ===== 3.1.28-dev===== (xx.xx.2015) 24.10.2015 - new extension handler to load functions when called + - improve recovery from ivalid compiled template code 21.10.2015 - move some code into runtime extensions diff --git a/libs/sysplugins/smarty_internal_testinstall.php b/libs/sysplugins/smarty_internal_testinstall.php index a89f62c6..8562990e 100644 --- a/libs/sysplugins/smarty_internal_testinstall.php +++ b/libs/sysplugins/smarty_internal_testinstall.php @@ -46,7 +46,7 @@ class Smarty_Internal_TestInstall if ($_stream_resolve_include_path) { $template_dir = stream_resolve_include_path($_template_dir); } else { - $template_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_template_dir, null, $smarty); + $template_dir = $smarty->ext->_getIncludePath->getIncludePath($_template_dir, null, $smarty); } if ($template_dir !== false) { @@ -165,7 +165,7 @@ class Smarty_Internal_TestInstall if ($_stream_resolve_include_path) { $plugin_dir = stream_resolve_include_path($_plugin_dir); } else { - $plugin_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_plugin_dir, null, $smarty); + $plugin_dir = $smarty->ext->_getIncludePath->getIncludePath($_plugin_dir, null, $smarty); } if ($plugin_dir !== false) { @@ -294,7 +294,7 @@ class Smarty_Internal_TestInstall if ($_stream_resolve_include_path) { $config_dir = stream_resolve_include_path($_config_dir); } else { - $config_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_config_dir, null, $smarty); + $config_dir = $smarty->ext->_getIncludePath->getIncludePath($_config_dir, null, $smarty); } if ($config_dir !== false) { diff --git a/libs/sysplugins/smarty_template_compiled.php b/libs/sysplugins/smarty_template_compiled.php index c13c4208..8cb29a64 100644 --- a/libs/sysplugins/smarty_template_compiled.php +++ b/libs/sysplugins/smarty_template_compiled.php @@ -142,7 +142,8 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base } $_template->smarty->compile_check = $compileCheck; } else { - include($_template->compiled->filepath); + $_template->mustCompile = true; + @include($_template->compiled->filepath); if ($_template->mustCompile) { $this->compileTemplateSource($_template); $compileCheck = $_template->smarty->compile_check; @@ -155,7 +156,8 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base !empty($_template->parent->compiled->includes) && $_template->smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_AUTOMATIC && !$_template->source->handler->recompiled && $_template->source->type != 'string' && - (!isset($_template->smarty->_cache['template_objects']) || !isset($_template->smarty->_cache['template_objects'][$_template->_getTemplateId()])) + (!isset($_template->smarty->_cache['template_objects']) || + !isset($_template->smarty->_cache['template_objects'][$_template->_getTemplateId()])) ) { foreach ($_template->parent->compiled->includes as $key => $count) { $_template->compiled->includes[$key] = @@ -164,7 +166,8 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base } $key = $_template->source->type . ':' . $_template->source->name; if (isset($_template->compiled->includes[$key]) && $_template->compiled->includes[$key] > 1) { - $_template->smarty->_cache['template_objects'][isset($_template->templateId) ? $_template->templateId : $_template->_getTemplateId()] = $_template; + $_template->smarty->_cache['template_objects'][isset($_template->templateId) ? $_template->templateId : + $_template->_getTemplateId()] = $_template; } } $this->processed = true; @@ -183,7 +186,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base } $_smarty_tpl = $_template; if (strpos(phpversion(), 'hhvm') !== false) { - Smarty_Internal_Extension_Hhvm::includeHhvm($_template, $_template->compiled->filepath); + $_template->smarty->ext->_hhvm->includeHhvm($_template, $_template->compiled->filepath); } else { include($_template->compiled->filepath); } @@ -277,8 +280,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base public function write(Smarty_Internal_Template $_template, $code) { if (!$_template->source->handler->recompiled) { - $obj = new Smarty_Internal_Write_File(); - if ($obj->writeFile($this->filepath, $code, $_template->smarty) === true) { + if ($_template->smarty->ext->_writeFile->writeFile($this->filepath, $code, $_template->smarty) === true) { $this->timestamp = $this->exists = is_file($this->filepath); if ($this->exists) { $this->timestamp = filemtime($this->filepath);