- bugfix added missing support of $cache_attrs for registered plugins

This commit is contained in:
uwe.tews@googlemail.com
2010-12-17 21:05:29 +00:00
parent 6d897f0d59
commit b9477b0deb
5 changed files with 12 additions and 5 deletions

View File

@@ -1,6 +1,9 @@
===== SVN trunk =====
17/12/2010
- bugfix added missing support of $cache_attrs for registered plugins
15/12/2010
- bugfix assigment as condition in {while} did drop an E_NOTICE
- bugfix assignment as condition in {while} did drop an E_NOTICE
14/12/2010
- bugfix when passing an array as default parameter at {function} tag

View File

@@ -41,6 +41,9 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
foreach ($_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} elseif ($this->compiler->template->caching && in_array($_key,$compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag][2])) {
$_value = str_replace("'","^#^",$_value);
$_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
} else {
$_paramsArray[] = "'$_key'=>$_value";
}

View File

@@ -43,6 +43,9 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
foreach ($_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} elseif ($this->compiler->template->caching && in_array($_key,$compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag][2])) {
$_value = str_replace("'","^#^",$_value);
$_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
} else {
$_paramsArray[] = "'$_key'=>$_value";
}

View File

@@ -35,10 +35,7 @@ class Smarty_Internal_Register {
} elseif (!is_callable($callback)) {
throw new Exception("Plugin \"{$tag}\" not callable");
} else {
$this->smarty->registered_plugins[$type][$tag] = array($callback, (bool) $cacheable);
if (isset($cache_attr)&&in_array($type, array(Smarty::PLUGIN_BLOCK, Smarty::PLUGIN_FUNCTION))) {
$this->smarty->registered_plugins[$type][$tag][] = (array) $cache_attr;
}
$this->smarty->registered_plugins[$type][$tag] = array($callback, (bool) $cacheable, (array) $cache_attr);
}
}

View File

@@ -364,6 +364,7 @@ class Smarty_Internal_TemplateCompilerBase {
($this->nocache || $this->tag_nocache || $this->template->forceNocache == 2)) {
$this->template->has_nocache_code = true;
$_output = str_replace("'", "\'", $content);
$_output = str_replace("^#^", "'", $_output);
$_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output . "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>";
// make sure we include modifer plugins for nocache code
if (isset($this->template->saved_modifier)) {