|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
ndorphin Smarty Rookie
Joined: 24 Dec 2009 Posts: 15 Location: Berlin, Germany
|
Posted: Wed Jul 27, 2011 3:12 pm Post subject: Bug 3.08: caching of subtemplates used more then 1x |
|
|
Hi,
in Smarty 3.08 seems to be a bug (3.06 is ok) in caching if you use a subtemplates more than 1x from different template files. I have created a simple test case to show the bug:
Code: |
[test.php]
include_once(../Smarty.class.php');
$array1 = array(1,2,3);
$array2 = array(4,5,6);
$smarty = new Smarty();
$smarty->assign('array1', $array1);
$smarty->assign('array2', $array2);
$smarty->setCaching(Smarty::CACHING_LIFETIME_CURRENT);
$smarty->display('test.tpl');
[test.tpl]
{include file='sub.tpl'}
{foreach $array2 as $var}
{include file='sub2.tpl'}
{/foreach}
[sub.tpl]
{foreach $array1 as $var}
{include file='sub2.tpl'}
{/foreach}
[sub2.tpl]
{$var}
|
expected output as in 3.06 (and 3.08 non cached)
1 2 3 4 5 6
output in 3.08
1 2 3 3 3 3
Smarty 3.08 try to read the subtemplate somewhere from cache before it will be rendered and there must be the bug, Smarty 3.06 calls simple new Smarty_Internal_Template and all is fine:
Code: |
<?php $sha = sha1('sub.tpl' . $_smarty_tpl->cache_id . $_smarty_tpl->compile_id);
if (isset($_smarty_tpl->smarty->template_objects[$sha])) {
$_template = $_smarty_tpl->smarty->template_objects[$sha]; $_template->caching = 9999; $_template->cache_lifetime = null;
} else {
$_template = new Smarty_Internal_Template('sub.tpl', $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 9999, null);
}
echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?>
|
thanks n.dorphin[/code] |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Jul 27, 2011 4:49 pm Post subject: |
|
|
thanks for your input.
This bug is fixed now in the SVN trunk version. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|