cvs: smarty /libs Smarty.class.php
| From: | Messju Mohr | Date: | Mon, 14 Apr 2003 07:31:42 +0000 |
| Subject: | cvs: smarty /libs Smarty.class.php | ||
| Groups: | php.smarty.cvs | ||
| Request: | Send a blank email to php-smarty-cvs+get-519@lists.php.net to get a copy of this message | ||
messju Mon Apr 14 03:31:42 2003 EDT
Modified files:
/smarty/libs Smarty.class.php
Log:
fixed bug with nested calls to fetch() when caching enabled
Index: smarty/libs/Smarty.class.php
diff -u smarty/libs/Smarty.class.php:1.375 smarty/libs/Smarty.class.php:1.376
--- smarty/libs/Smarty.class.php:1.375 Fri Apr 11 09:40:40 2003
+++ smarty/libs/Smarty.class.php Mon Apr 14 03:31:42 2003
@@ -42,7 +42,7 @@
* @version 2.5.0
*/
-/* $Id: Smarty.class.php,v 1.375 2003/04/11 13:40:40 mohrt Exp $ */
+/* $Id: Smarty.class.php,v 1.376 2003/04/14 07:31:42 messju Exp $ */
/**
* set SMARTY_DIR to absolute path to Smarty library files.
@@ -1065,6 +1065,8 @@
*/
function fetch($tpl_file, $cache_id = null, $compile_id = null, $display = false)
{
+ static $_cache_info = array();
+
$_smarty_old_error_level = $this->debugging ? error_reporting() :
error_reporting(error_reporting() & ~E_NOTICE);
if($this->security && !in_array($this->template_dir, $this->secure_dir)) {
@@ -1095,11 +1097,9 @@
$this->_inclusion_depth = 0;
if ($this->caching) {
- if(!empty($this->_cache_info)) {
- // nested call, init cache_info
- $_cache_info = $this->_cache_info;
- $this->_cache_info = array();
- }
+ // save old cache_info, initialize cache_info
+ array_push($_cache_info, $this->_cache_info);
+ $this->_cache_info = array();
if ($this->_read_cache_file($tpl_file, $cache_id, $compile_id, $_smarty_results)) {
if (@count($this->_cache_info['insert_tags'])) {
$this->_load_plugins($this->_cache_info['insert_tags']);
@@ -1127,9 +1127,13 @@
echo $_smarty_results;
}
error_reporting($_smarty_old_error_level);
+ // restore initial cache_info
+ $this->_cache_info = array_pop($_cache_info);
return true;
} else {
error_reporting($_smarty_old_error_level);
+ // restore initial cache_info
+ $this->_cache_info = array_pop($_cache_info);
return $_smarty_results;
}
} else {
@@ -1138,10 +1142,6 @@
header("Last-Modified: ".gmdate('D, d M Y H:i:s',
time()).' GMT');
}
}
- if(isset($_cache_info)) {
- // restore cache_info
- $this->_cache_info = $_cache_info;
- }
}
if (count($this->autoload_filters)) {
@@ -1174,6 +1174,8 @@
if ($this->caching) {
$this->_write_cache_file($tpl_file, $cache_id, $compile_id, $_smarty_results);
$_smarty_results = $this->_process_cached_inserts($_smarty_results);
+ // restore initial cache_info
+ $this->_cache_info = array_pop($_cache_info);
}
if ($display) {