bug with config_load and caching
| From: | Nagger | Date: | Wed, 12 Mar 2003 00:39:38 +0000 |
| Subject: | bug with config_load and caching | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-945@lists.php.net to get a copy of this message | ||
Hello...
Sorry, the "re:" in the titel of my last post ("default-modifier causes a
php-notice") is of course wrong :(
Another thing:
I posted this last week in the general-list, but i've got no answer.
That's why here again:
There is a bug if you use the function "$smarty->config_load()" and have
enabled caching.
The name of the template file is NOT written in the cache file meta line
(the first line).
simple example:
---index.tpl---
foobar
---index.php---
$smarty = new Smarty;
$smarty->caching = true;
$smarty->config_load('test.conf');
$smarty->display('index.tpl');
the resulting line in cache file:
a:3:{s:6:"config";a:1:{i:0;s:9:"test.conf";}s:9:"timestamp";i:1047001755;s:7
:"expires";i:1047005355;}
As you can see there is no "template"-key.
I think the bug is in 'smarty.class.php' function 'fetch()':
line 1100: $this->_cache_info is saved in $_cache_info and unset after that
(because of the "config_load()" the array was not empty) but its not a
nested fetch!!!
line 1136: $this->_cache_info['template'][] = $_smarty_tpl_file;
(the template name is set here correctly)
line 1143: $this->_cache_info is restored from $_cache_info
!!!THIS IS THE BUG!!!
Appending here (line 1143+) a
if (!isset($_cache_info['template'])) $this->_cache_info['template'][] =
$_smarty_tpl_file;
could/should correct the problem, but I'm not sure. Maybe there are some
side effects.
Bye...
Nagger