View previous topic :: View next topic |
Author |
Message |
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Jun 14, 2010 5:44 pm Post subject: Smarty 3 RC2 released |
|
|
The second RC of Smarty 3 has been released! Please join the developer mailing list and see the Smarty 3 section of the forums and give us feedback!
NOTE: Documentation for Smarty 3 is still being finalized, please use the README for now.
http://www.smarty.net/ |
|
Back to top |
|
Mastershrimp Smarty Regular
Joined: 21 Dec 2009 Posts: 53
|
Posted: Mon Jun 14, 2010 8:43 pm Post subject: |
|
|
Thanks! Great job!
I just updated yesterday on RC1....
Well, I encountered some problems with an own template function of mine. In PHP5.3 there is a warning about the $smarty parameter being "expected to be a reference, value given". I correctly wrote "&$smarty" in the function's definition and PHP5.2.x worked fine.
After googleing and searching the forum I solved the problem by simply removing the "&"...but is that really a good solution?
Maybe you should investigate that problem since it seems that several other users in this problem are facing this problem as well.
Note: I used the RC1 and didnt check whether it still occurs in RC2. But since the changelog didt say anyting like that I think it's still an issue.
Still, great Job! Looking forward to the final! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Jun 14, 2010 8:48 pm Post subject: |
|
|
Normally this is a difference between PHP4 and PHP5, as it handles references differently. When you upgrade to PHP5 you may remove & in lots of places in your scripts. Are you sure this isn't a difference in PHP behavior and not Smarty?
ed: you might also see this if you pass a scalar value such as null or a "string" as a property expecting a reference to a variable. so if you have:
function foobar($foo,&$bar) { ... }
and you call it as:
foobar($foo,null);
error! then remove the & and it works. |
|
Back to top |
|
vorapoap Smarty Rookie
Joined: 22 Dec 2009 Posts: 32
|
Posted: Wed Jun 16, 2010 1:42 pm Post subject: Template Function Scope |
|
|
Oh.. sorry.. my problem solved after clearing all the cache...
Thank you for this great library.
[removed]
Any one if have a problem after replacing Smarty with the new version, you may like to try clearing template caches first. |
|
Back to top |
|
vorapoap Smarty Rookie
Joined: 22 Dec 2009 Posts: 32
|
Posted: Wed Jun 16, 2010 4:29 pm Post subject: |
|
|
OK this is really a bug.
I register a compiler function via $smarty->register->compilerFunction("t", "_compiler_t");
In template
In php
Code: |
function _compiler_t($args, $smarty) {
return "\n<?php echo _('". str_replace("'", "\\'", $args['t'])."'); ?>";
}
|
Firstly, $args['t'] always contains starting and tailing quotes, no matter it is double (") or single(')
Secondly, in Smarty2, I don't think we need to return <?php .. ?> ? Probably this is now changed in Smarty3 |
|
Back to top |
|
VEG Smarty Rookie
Joined: 02 May 2010 Posts: 20 Location: Belarus
|
Posted: Tue Jul 06, 2010 7:58 am Post subject: |
|
|
In Smarty 2 $smarty.template contains relative path to template and filename. In Smarty 3 this variable contains only filename. Is it correct behaviour? |
|
Back to top |
|
VEG Smarty Rookie
Joined: 02 May 2010 Posts: 20 Location: Belarus
|
Posted: Tue Jul 06, 2010 8:07 am Post subject: |
|
|
And maybe you add deprecation notice for foreach with with identical from and item attributes.
Code: | {foreach item=blah from=$blah}
{$blah}
{/foreach}
| This code correctly works in Smarty 2 and don't works in Smarty 3 at all. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Jul 06, 2010 12:52 pm Post subject: |
|
|
VEG wrote: | And maybe you add deprecation notice for foreach with with identical from and item attributes.
Code: | {foreach item=blah from=$blah}
{$blah}
{/foreach}
| This code correctly works in Smarty 2 and don't works in Smarty 3 at all. |
It really shouldn't work. Why would you give the loop the same name as the looped variable? That is like doing this in PHP:
foreach($foo as $foo) |
|
Back to top |
|
VEG Smarty Rookie
Joined: 02 May 2010 Posts: 20 Location: Belarus
|
Posted: Tue Jul 06, 2010 1:04 pm Post subject: |
|
|
This code works perfectly and outputs "123" in PHP 5 Code: | <?php
$a = array(1,2,3);
foreach($a as $a)
{
echo($a);
}
?> |
I know that is very bad style, but many old codes uses this bug (or feature =) ). Maybe you add error output or deprecation notice for this case? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Jul 06, 2010 1:08 pm Post subject: |
|
|
hmm. I guess I didn't realize PHP would actually support it. If it's easy enough we might allow it in the parser, but not make note that it's an option. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Jul 06, 2010 7:08 pm Post subject: |
|
|
{foreach item=blah from=$blah} did loop correctly in Smarty2 but did create also problems if you wanted to use the original value of array $blah later on, as the loop did overwrite the original value.
There is a patch in the SVN now which throws an exception in this condition. |
|
Back to top |
|
VEG Smarty Rookie
Joined: 02 May 2010 Posts: 20 Location: Belarus
|
Posted: Tue Jul 06, 2010 10:10 pm Post subject: |
|
|
U.Tews, Thank you.
What about VEG wrote: | In Smarty 2 $smarty.template contains relative path to template and filename. In Smarty 3 this variable contains only filename. Is it correct behaviour? |
|
|
Back to top |
|
Mastershrimp Smarty Regular
Joined: 21 Dec 2009 Posts: 53
|
Posted: Thu Jul 15, 2010 6:20 am Post subject: |
|
|
mohrt wrote: | Normally this is a difference between PHP4 and PHP5, as it handles references differently. When you upgrade to PHP5 you may remove & in lots of places in your scripts. Are you sure this isn't a difference in PHP behavior and not Smarty? |
Sorry for my late response, I didnt check this thread for quite some time...
To your question: I dont know actually. I'm using PHP5 since years, and just recently updated Smarty - so I guessed it's Smarty's fault....?
Well, and it seems to be PHP5.3-specific... |
|
Back to top |
|
|