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

Two templates compile to the same function name

 
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
Estigy
Smarty Rookie


Joined: 16 Nov 2011
Posts: 5

PostPosted: Tue Feb 07, 2012 11:19 am    Post subject: Two templates compile to the same function name Reply with quote

Hi.

Smarty templates compile to functions named "content_" + uniqid('', false).

On our high traffic site, every now and then two different templates get compiled to the same function name, resulting in some very weird output: On the place, where the second template is to be inserted, the first template (with the same function name already in memory) shows up.

The code can be found 2x in smarty_internal_template.php and 1x in smarty_internal_compile_include.php.

I strongly encourage not only using uniqid() for generating the function name. Please add a checksum of the code or the filename to the identifier.

Thanks,
Estigy.
Back to top
View user's profile Send private message
Estigy
Smarty Rookie


Joined: 16 Nov 2011
Posts: 5

PostPosted: Tue Feb 07, 2012 11:25 am    Post subject: Reply with quote

Hi.

I did a quickfix for this that seems to work for me. The lines now look like this:

.... = 'content_' . str_replace('.', '_', uniqid('', true));

Including the content-hash or the filename still seems a better to do this, though.

Greets, E.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue Feb 07, 2012 6:55 pm    Post subject: Reply with quote

This has been fixed in the SVN trunk and will be include in 3.1.8
Back to top
View user's profile Send private message
Estigy
Smarty Rookie


Joined: 16 Nov 2011
Posts: 5

PostPosted: Thu Feb 09, 2012 8:34 am    Post subject: Reply with quote

Thanks! Smile
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