diff --git a/change_log.txt b/change_log.txt index 1fc5fc5d..1621b04f 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +01/09/2009 +- bugfix on nocache {block} tags in parent templates + 01/08/2009 - bugfix on variable filters. filter/nofilter attributes did not work on output statements diff --git a/libs/sysplugins/smarty_internal_compile_block.php b/libs/sysplugins/smarty_internal_compile_block.php index 54798ef4..4a4cd542 100644 --- a/libs/sysplugins/smarty_internal_compile_block.php +++ b/libs/sysplugins/smarty_internal_compile_block.php @@ -30,7 +30,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { $this->_open_tag('block', $save); $compiler->template->extract_code = true; $compiler->template->extracted_compiled_code = ''; - $compiler->template->has_code = false; + $compiler->has_code = false; return true; } } @@ -66,7 +66,11 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase { $_tpl = $this->smarty->createTemplate('string:' . $this->smarty->block_data[$_name]['source'], null, null, $compiler->template); $_tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash']; $_tpl->template_filepath = $this->smarty->block_data[$_name]['file']; - $_tpl->forceNocache = true; + if ($compiler->nocache) { + $_tpl->forceNocache = 2; + } else { + $_tpl->forceNocache = 1; + } $_tpl->suppressHeader = true; $_tpl->suppressFileDependency = true; if (strpos($this->smarty->block_data[$_name]['source'], '%%%%SMARTY_PARENT%%%%') !== false) { @@ -87,7 +91,9 @@ 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]; + // $_output content has already nocache code processed + $compiler->suppressNocacheProcessing = true; return $_output; } } diff --git a/libs/sysplugins/smarty_internal_compile_function.php b/libs/sysplugins/smarty_internal_compile_function.php index 7ebf5e47..10735bf8 100644 --- a/libs/sysplugins/smarty_internal_compile_function.php +++ b/libs/sysplugins/smarty_internal_compile_function.php @@ -40,8 +40,8 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase { $compiler->template->required_plugins = array('compiled' => array(), 'cache' => array()); $compiler->template->extract_code = true; $compiler->template->extracted_compiled_code = ''; - $compiler->template->has_code = false; $compiler->template->has_nocache_code = false; + $compiler->has_code = false; return true; } } diff --git a/libs/sysplugins/smarty_internal_smartytemplatecompiler.php b/libs/sysplugins/smarty_internal_smartytemplatecompiler.php index 04799b0c..2246f035 100644 --- a/libs/sysplugins/smarty_internal_smartytemplatecompiler.php +++ b/libs/sysplugins/smarty_internal_smartytemplatecompiler.php @@ -39,10 +39,10 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom // init the lexer/parser to compile the template $this->lex = new $this->lexer_class($_content, $this); $this->parser = new $this->parser_class($this->lex, $this); - // $this->parser->PrintTrace(); + if (isset($this->smarty->_parserdebug)) $this->parser->PrintTrace(); // get tokens from lexer and parse them while ($this->lex->yylex() && !$this->abort_and_recompile) { - // echo "
Line {$this->lex->line} Parsing {$this->parser->yyTokenName[$this->lex->token]} Token ".htmlentities($this->lex->value).""; + if (isset($this->smarty->_parserdebug)) echo "
Line {$this->lex->line} Parsing {$this->parser->yyTokenName[$this->lex->token]} Token ".htmlentities($this->lex->value).""; $this->parser->doParse($this->lex->token, $this->lex->value); } diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index 1e927bc7..61374ed3 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -12,6 +12,10 @@ * Main compiler class */ class Smarty_Internal_TemplateCompilerBase { + // hash for nocache sections + private $nocache_hash = null; + // suppress generation of nocache code + public $suppressNocacheProcessing = false; // compile tag objects static $_tag_objects = array(); // tag stack @@ -20,8 +24,6 @@ class Smarty_Internal_TemplateCompilerBase { public $template = null; // required plugins public $required_plugins_call = array(); - // hash for nocache sections - private $nocache_hash = null; /** * Initialize compiler @@ -331,10 +333,10 @@ class Smarty_Internal_TemplateCompilerBase { public function processNocacheCode ($content, $is_code) { // If the template is not evaluated and we have a nocache section and or a nocache tag - if ($is_code) { + if ($is_code && !empty($content)) { // generate replacement code - if ((!$this->template->resource_object->isEvaluated || $this->template->forceNocache) && $this->template->caching && - ($this->nocache || $this->tag_nocache)) { + if ((!$this->template->resource_object->isEvaluated || $this->template->forceNocache) && $this->template->caching && !$this->suppressNocacheProcessing && + ($this->nocache || $this->tag_nocache || $this->template->forceNocache == 2)) { $this->tag_nocache = false; $this->template->has_nocache_code = true; $_output = str_replace("'", "\'", $content); @@ -354,6 +356,7 @@ class Smarty_Internal_TemplateCompilerBase { } else { $_output = $content; } + $this->suppressNocacheProcessing = false; return $_output; } /**