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

Problem with compileAllTemplates

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


Joined: 16 Feb 2010
Posts: 9

PostPosted: Thu Sep 16, 2010 4:32 pm    Post subject: Problem with compileAllTemplates Reply with quote

Hello,

First problem

some_template.htm:

{extends file="main_template.htm"}
{block name="content"}
bla bla bla bla
{/block}

Changes in main_template.htm are NOT detected when running compileAllTemplates in a seperate compile script (CLI). Setting compile_check = true and requesting the template the normale way ($smarty->display('some_template.htm'); does recompile some_template.htm when there is a change in main_template.htm. It does work as expected when there is a change in some_template.htm (both ways).

Second problem

For some reason compileAllTemplates adds a an extra slash ($_template_file):

ie

/some/path/to/templates//some_template.htm

and thus the SHA1 or MD5 hash prefixing the compiled template does not match and I end up with two compiled versions (one created by compileAllTemplates and one by the normal way of $smarty->display()).

I added a simple fix:

// Remove leading slashes
$_template_file = preg_replace('/^\//', '', $_template_file);

Is there something I am doing wrong or a hidden feature? Smile

Thanks,

PS I am using revision 3667
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Fri Sep 17, 2010 12:41 pm    Post subject: Reply with quote

First problem

Yes, compileAllTemplates does not detect file dependencies when called with the force_compile = false parameter setting on templates using template inheritance. This is caused by the way template inhertance works. It has no 1:1 relationship between template source and compiled files and also compilechecking works completely different.

It does work when you use force_compile = true. compiileAllTemplates started as some experimental code to compile all templates of line after internal script changes at a time before we ever thought about template inheritance.

There is no quick fix, but I will put it on the todo list.


Second problem

I can't reproduce the problem.

How did you define the template_dir path?
Where did you see and remove the leading slash?
Back to top
View user's profile Send private message
stayclose
Smarty Rookie


Joined: 16 Feb 2010
Posts: 9

PostPosted: Fri Sep 17, 2010 1:23 pm    Post subject: Reply with quote

Hi Uwe,

Regarding the first problem: it is pretty annoying the way it works now but I understand why it is the way it is. Perhaps I did not get the right idea of template inheriting and thus made a design error on my part.

The second problem.

I added the following to

sysplugins/smarty_internal_utility.php, line 75:

printf("function compileAllTemplates: _template_file (no change): %s\n", $_template_file);

// Remove leading slashes
$_template_file = preg_replace('/^\//', '', $_template_file);

printf("function compileAllTemplates: _template_file (changed): %s\n", $_template_file);

My template dir is set to

/some/path/to/templates

and NOT

/some/path/to/templates/

So, if I run my compile script I get the following output:


function compileAllTemplates: _template_file (no change): /some_template.htm
function compileAllTemplates: _template_file (changed): some_template.htm

If I don't do this, I end up with the following in the compiled version:

<?php /* Smarty version Smarty3-SVN$Rev: etc $, created on etc
compiled from "/some/path/to/templates//some_template.htm" */ ?>

And I believe you do a SHA1/MD5 hash on the full path of the template resulting in a hash mismatch and thus creating a new compiled template.

I hope this helps.

Peter
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Fri Sep 17, 2010 6:43 pm    Post subject: Reply with quote

Hi Peter

A fix for the second problem is in the SVN now.
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