Re: [SMARTY] serious bug? insert tags are cached???

From: Date: Fri, 16 Aug 2002 01:29:27 +0000
Subject: Re: [SMARTY] serious bug? insert tags are cached???
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-246@lists.php.net to get a copy of this message
hi all! i think i found the bug i described on the smarty-general list under the same subject, but i have no solution, perhaps someone can help me. try the following: insert.php -------------------- require_once ( "Smarty.class.php" ); $smarty = new Smarty; $smarty->caching = 1; $smarty->cache_lifetime = 30; $smarty->display ( "insert.tpl" ); -------------------- plugins/insert.test.php -------------------- function smarty_insert_test($params, &$smarty) { extract ( $params ); return "TEXT:".$text; } -------------------- plugins/function.test.php -------------------- function smarty_function_test($params, &$smarty) { //$cache_info = $smarty->_cache_info; $smarty->display("test.tpl"); //$smarty->_cache_info = $cache_info; } -------------------- templates/insert.tpl -------------------- {insert name="test" text="TEST"}<br> {test}<br> -------------------- templates/test.tpl -------------------- TEST -------------------- you will see caching won't work. this is because of the $_cache_info variable in smarty. first, this variable will be ok, but then the call to $smarty->display in smarty_function_test will reset $_cache_info['insert_tags'] so that the generated cache/insert.tpl.php will get a wrong cache header viz without the information in $_cache_info['insert_tags']. so on the next execution of insert.php the insert_cache tag in the cached file will not be evaluated, because of the missing $_cache_info['insert_tags'] information in the cache header. uncomment the two lines in plugins/function.test.php and you will see it works, but i don't think this is the right way. i think smarty should handle this. it took me a whole day to hack me into smarty caching. perhaps someone is more involed in that and can help me. thanks, rainer

« previous php.smarty.dev (#246) next »