smarty icon indicating copy to clipboard operation
smarty copied to clipboard

"Invalid compiled template for...." only on first load with caching enabled [Smarty 3.1.40]

Open ddowie opened this issue 3 years ago • 4 comments

Hi, Smarty throws exception when I include the same template with the same cache_id more than once in one page. I am trying to display the same cached product card in the main menu and then later in slider again. It happens only on first load when cache is building. After reload it works.

exception

SmartyException 
  #message: "Invalid compiled template for 'file:product-card.tpl'"

settings

$marty->caching = 1;
$marty->compile_check = false;
$marty->force_compile = false;

home.tpl

{include file="menu.tpl"}

<div id="slider">
    <div class="item">
        {include file="product-card.tpl" cache_id="product|1"}
    </div>
</div>

menu.tpl

<ul>
    <li>Home</li>
    <li>About us</li>
    <li>Newest product:
        {include file="product-card.tpl" cache_id="product|1"}
    </li>
</ul>

ddowie avatar Dec 31 '21 11:12 ddowie

How to reproduce: index.php test.tpl menu.tpl product-card.tpl

If $smarty->caching = 1; and cache/compiles are deleted, on the first load "Invalid compiled template error" occurs. If $smarty->caching = 0; and cache/compiles are deleted, on the first load "Fatal error: Uncaught Error: Maximum function nesting level of '1000' reached, aborting! in vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php on line 734 (https://pasteboard.co/hl6QkaennNTt.png))

After the first load everything works in both cases as it should. If I add different compile_id as parameter to included template it all works from the first time {include file="product-card.tpl" cache_id='product|1' compile_id='test'} BUT in this case duplicated cache file is generated with the same content which I would like to avoid if possible.

Please help :)

ddowie avatar Dec 31 '21 14:12 ddowie

Same issue here... any fix or workaround?

danihuge avatar Aug 25 '22 13:08 danihuge

Workaround is to add different compile ID for the same - included subtemplate with same cache ID at different location.

ddowie avatar Aug 25 '22 15:08 ddowie

Same here... will look deeper... thanks!

danihuge avatar Aug 25 '22 16:08 danihuge