diff --git a/change_log.txt b/change_log.txt index 85c2eb4e..1b80daa8 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,5 +1,7 @@ 11/03/2009 - fixed parser error on objects with special smarty vars +- fixed file dependency for {incude} inside {block} tag +- fixed not compiling on non existing compiled templates when compile_check = false 11/02/2009 - added neq,lte,gte,mod as aliases to if conditions diff --git a/libs/sysplugins/smarty_internal_compile_block.php b/libs/sysplugins/smarty_internal_compile_block.php index d5d49a83..8cb59644 100644 --- a/libs/sysplugins/smarty_internal_compile_block.php +++ b/libs/sysplugins/smarty_internal_compile_block.php @@ -26,11 +26,11 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { $this->optional_attributes = array('assign'); // check and get attributes $_attr = $this->_get_attributes($args); - $save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code); + $save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code); $this->_open_tag('block', $save); $compiler->template->extract_code = true; $compiler->template->extracted_compiled_code = ''; - $compiler->template->has_code = false; + $compiler->template->has_code = false; return true; } } @@ -76,7 +76,14 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase { $_output = $compiler->template->extracted_compiled_code; } $compiler->template->extracted_compiled_code = $saved_data[1]; - $compiler->template->extract_code = $saved_data[2]; + $compiler->template->extract_code = $saved_data[2]; + // check for includes in block tags + preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $_output, $matches); + $_output = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/', '/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $_output); + if (isset($matches[2])) { + $prop = unserialize($matches[2]); + $compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']); + } return $_output; } } diff --git a/libs/sysplugins/smarty_internal_compile_extend.php b/libs/sysplugins/smarty_internal_compile_extend.php index a6e160c4..d4b06cb9 100644 --- a/libs/sysplugins/smarty_internal_compile_extend.php +++ b/libs/sysplugins/smarty_internal_compile_extend.php @@ -58,7 +58,7 @@ class Smarty_Internal_Compile_Extend extends Smarty_Internal_CompileBase { // compile block content $_tpl = $this->smarty->createTemplate('string:' . $block_content); $_tpl->template_filepath = $this->compiler->template->getTemplateFilepath(); - $_tpl->suppressFileDependency = true; +// $_tpl->suppressFileDependency = true; $_compiled_content = $_tpl->getCompiledTemplate(); unset($_tpl); $_name = trim($_match[3], "\"'}"); diff --git a/libs/sysplugins/smarty_internal_resource_extend.php b/libs/sysplugins/smarty_internal_resource_extend.php index 28d57e47..7fe30f30 100644 --- a/libs/sysplugins/smarty_internal_resource_extend.php +++ b/libs/sysplugins/smarty_internal_resource_extend.php @@ -111,7 +111,7 @@ class Smarty_Internal_Resource_Extend { // compile block content $_tpl = $this->smarty->createTemplate('string:' . $block_content); $_tpl->template_filepath = $this->template->getTemplateFilepath(); - $_tpl->suppressFileDependency = true; +// $_tpl->suppressFileDependency = true; $_compiled_content = $_tpl->getCompiledTemplate(); unset($_tpl); $_name = trim($_match[3], "\"'}"); diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index 87fa49db..031b7990 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -210,7 +210,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { { $this->isExisting(true); if ($this->mustCompile === null) { - $this->mustCompile = ($this->usesCompiler() && ($this->force_compile || $this->isEvaluated() || ($this->smarty->compile_check && $this->getCompiledTimestamp () !== $this->getTemplateTimestamp ()))); + $this->mustCompile = ($this->usesCompiler() && ($this->force_compile || $this->isEvaluated() || $this->getCompiledTimestamp () === false || + ($this->smarty->compile_check && $this->getCompiledTimestamp () !== $this->getTemplateTimestamp ()))); } return $this->mustCompile; } @@ -370,11 +371,11 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { if ($this->getCachedTimestamp() === false) { return $this->isCached; } - if (($this->caching == SMARTY_CACHING_LIFETIME_SAVED || ($this->caching == SMARTY_CACHING_LIFETIME_CURRENT && (time() <= ($this->getCachedTimestamp() + $this->cache_lifetime) || $this->cache_lifetime < 0)))) { + if ($this->caching === SMARTY_CACHING_LIFETIME_SAVED || ($this->caching && (time() <= ($this->getCachedTimestamp() + $this->cache_lifetime) || $this->cache_lifetime < 0))) { $_start_time = $this->_get_time(); $this->rendered_content = $this->cache_resource_object->getCachedContents($this); $this->cache_time += $this->_get_time() - $_start_time; - if ($this->caching == SMARTY_CACHING_LIFETIME_SAVED && $this->properties['cache_lifetime'] >0 && (time() > ($this->getCachedTimestamp() + $this->properties['cache_lifetime']))) { + if ($this->caching === SMARTY_CACHING_LIFETIME_SAVED && $this->properties['cache_lifetime'] >0 && (time() > ($this->getCachedTimestamp() + $this->properties['cache_lifetime']))) { $this->rendered_content = null; return $this->isCached; }