Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Smarty3 Subtemplates caching is too aggressive

 
Post new topic   Reply to topic    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
Anton Gridasov
Smarty n00b


Joined: 26 Jan 2018
Posts: 3

PostPosted: Fri Jan 26, 2018 11:34 am    Post subject: Smarty3 Subtemplates caching is too aggressive Reply with quote

Our project has different language versions of templates for different domains, some of them are identical so we use includes:

en_DE/welcome.tpl:
Code:
Welcome {$user}


en_EU/welcome.tpl:
Code:
{include file="en_DE/welcome.tpl"}


When template en_EU/welcome.tpl is rendered more then one time during run session, subtemplate en_DE/welcome.tpl is cached. If we try to render subtemplate directly we got cached version.

Code:
<?php
require '../libs/Smarty.class.php';

$smarty = new Smarty;
$smarty->caching = false;

$smarty->assign('user', 'Alex');
$result = $smarty->fetch('en_EU/welcome.tpl');
$result = $smarty->fetch('en_EU/welcome.tpl');

echo $result . "\n";
// Welcome Alex


$smarty->assign('user', 'Tom');
$result = $smarty->fetch('en_DE/welcome.tpl');

echo $result . "\n";
// Welcome Alex
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1294

PostPosted: Sat Jan 27, 2018 12:03 pm    Post subject: Reply with quote

You can use compile_id when you want to build two template sets from one template source.
Different compile_id's are cached separately.
Back to top
View user's profile Send private message
Anton Gridasov
Smarty n00b


Joined: 26 Jan 2018
Posts: 3

PostPosted: Sun Jan 28, 2018 8:45 am    Post subject: Reply with quote

I found that dev branch already has a fix for the bug

https://github.com/smarty-php/smarty/commit/3f0d519daf26c4937b132845e5b1c1f97e410a38


Sorry, I had to check this before posting
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1294

PostPosted: Sun Jan 28, 2018 11:40 am    Post subject: Reply with quote

Oh, good to know. Didn't experience this issue myself.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1294

PostPosted: Sun Jan 28, 2018 11:43 am    Post subject: Reply with quote

By the way, 3.1.31 release supposedly contains this patch.
https://github.com/smarty-php/smarty/compare/v3.1.30...v3.1.31
Back to top
View user's profile Send private message
Anton Gridasov
Smarty n00b


Joined: 26 Jan 2018
Posts: 3

PostPosted: Sun Jan 28, 2018 2:03 pm    Post subject: Reply with quote

Is it final stable version 3.1.31?

Download page contains link to release 3.1.30 https://www.smarty.net/download

And release 3.1.31 marked with comment 'prepare 3.1.31 release'

I'm a bit confused which version to use for production
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1294

PostPosted: Sun Jan 28, 2018 4:37 pm    Post subject: Reply with quote

Did I say "3.1.31 release"?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP