From a0b874850a29b02d37bd0d4970abaf963aa4f6c3 Mon Sep 17 00:00:00 2001 From: messju Date: Thu, 7 Aug 2003 11:35:46 +0000 Subject: [PATCH] better caching of attributes for $cacheable=false-plugins --- libs/Smarty.class.php | 24 ++++++++++++++++++++++++ libs/Smarty_Compiler.class.php | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 6fe9b6c5..682e05f4 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -1999,6 +1999,30 @@ class Smarty } + /** + * get or set an array of cached attributes for function that is + * not cacheable + * @return array + */ + function &_smarty_cache_attrs($cache_serial, $count) { + $_cache_attrs =& $this->_cache_info['cache_attrs'][$cache_serial][$count]; + + if ($this->_cache_including) { + /* return next set of cache_attrs */ + $_return =& current($_cache_attrs); + next($_cache_attrs); + return $_return; + + } else { + /* add a reference to a new set of cache_attrs */ + $_cache_attrs[] = array(); + return $_cache_attrs[count($_cache_attrs)-1]; + + } + + } + + /** * wrapper for include() retaining $this * @return mixed diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 6062961a..859a5fbb 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -1294,7 +1294,7 @@ class Smarty_Compiler extends Smarty { /* we have a list of parameters that should be cached */ $_cache_attrs = $this->_plugins[$type][$name][5]; $_count = $this->_cache_attrs_count++; - $cache_code = "\$_cache_attrs =& \$this->_cache_info['cache_attrs']['$this->_cache_serial'][$_count];"; + $cache_code = "\$_cache_attrs =& \$this->_smarty_cache_attrs('$this->_cache_serial','$_count');"; } else { /* no parameters are cached */