Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Prefilters are applied twice with merge_compiled_includes on

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Mon Mar 26, 2012 8:35 pm    Post subject: Prefilters are applied twice with merge_compiled_includes on Reply with quote

If I register prefilter and disable merge_compiled_includes:
Code:
$smarty->merge_compiled_includes = false;
$smarty->registerFilter('pre', 'my_prefilter');

then this filter is executed once for each template or subtemplate.

If I register prefilter and enable merge_compiled_includes:
Code:
$smarty->merge_compiled_includes = false;
$smarty->registerFilter('pre', 'my_prefilter');

then this filter is executed twice for subtemplates. For example, if my filter adds some text to the end of template, then this text will be added twice.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Mar 26, 2012 9:41 pm    Post subject: Reply with quote

Which version of Smarty do you use?

I can't reproduce this problem with the latest version (3.1.Cool
Back to top
View user's profile Send private message
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Tue Mar 27, 2012 6:35 am    Post subject: Reply with quote

Code:
PHP:

include '../Smarty.class.php';

$smarty = new Smarty;

$smarty->compile_dir = '..';
$smarty->plugins_dir = '..';
$smarty->template_dir = '..';

$smarty->force_compile = true;
$smarty->merge_compiled_includes = true;

$smarty->registerFilter('pre', 'pre');

echo $smarty->fetch('a1.html');
echo $smarty->fetch('a2.html');

function pre($content) { return str_replace('word', '[word]', $content); }

=====

a1.html:
{include 'a3.html'}

=====

a2.html:
{include 'a3.html'}

=====

a3.html:
word

=====

Output:
[word][[word]]

=====

Expected output:
[word][word]


I am using SVN version.

I guess the situation when you fetch several templates or create several Smarty objects in one PHP script was not tested enough.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Mar 27, 2012 2:47 pm    Post subject: Reply with quote

Yes, you are right if same subtemplate is compiled into different main templates.

This has been fixed in the SVN trunk and will later be included in Smarty 3.1.9
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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