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

compile_check partially working

 
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 -> Smarty 3
View previous topic :: View next topic  
Author Message
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Thu Aug 18, 2011 7:58 am    Post subject: compile_check partially working Reply with quote

The description of the situation. I registered custom resource:

Code:
$smarty->registerResource('custom', array('cms_smarty_resource_get_template',
                                          'cms_smarty_resource_get_timestamp',
                                          'cms_smarty_resource_get_secure',
                                          'cms_smarty_resource_get_trusted'));


and disabled compile_check:

Code:
$smarty->compile_check = false;


I expect that after disabling compile_check cms_smarty_resource_get_timestamp function should never be called. However, this is not so. I admit that it is called less often, however it should not be called at all.

To help find the source of the problem, I added exeption to cms_smarty_resource_get_timestamp function and here is the trace:

Code:
0: cms_smarty_resource_get_timestamp(string{1}, false, object{Smarty})
1: call_user_func_array(string{1}, array{3}) in T:\HTDOCS\CMS\third_party\smarty\sysplugins\smarty_internal_resource_registered.php (73)
2: Smarty_Internal_Resource_Registered::getTemplateTimestamp(object{Smarty_Internal_Template}) in T:\HTDOCS\CMS\third_party\smarty\sysplugins\smarty_internal_template.php (129)
3: Smarty_Internal_Template::getTemplateTimestamp() in T:\HTDOCS\CMS\third_party\smarty\sysplugins\smarty_internal_resource_registered.php (43)
4: Smarty_Internal_Resource_Registered::isExisting(object{Smarty_Internal_Template}) in T:\HTDOCS\CMS\third_party\smarty\sysplugins\smarty_internal_template.php (160)
5: Smarty_Internal_Template::isExisting(true) in T:\HTDOCS\CMS\third_party\smarty\sysplugins\smarty_internal_template.php (552)
6: Smarty_Internal_Template::getRenderedTemplate() in T:\HTDOCS\CMS\third_party\smarty\Smarty.class.php (338)
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Thu Aug 18, 2011 8:16 am    Post subject: Reply with quote

the timestamp is used to determine if the template exists at all. Smarty infers that any integer > 0 returned by getTimestamp() means "template exists".

Are you using Smarty-3.0.8 or 3.1-RC1 or 3.1-DEV?
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Thu Aug 18, 2011 5:44 pm    Post subject: Reply with quote

I use Smarty-3.0.8.

This is just my opinion, but I think that if there is compiled version of the template then there is no need to check if uncompiled version of the template exists. At least when compile_check is disabled. We can just use compiled version. This will improve performance.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Aug 25, 2011 8:16 pm    Post subject: Reply with quote

Smarty3 can handle templates with same name from different source folders or resources by encoding filepath and resource into the compiled and cache filename.

So we need at least to check the existance of the main template source.

Compile_check = false tries to minimize teh overhead as much as possible.
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 -> Smarty 3 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