|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
SunWuKung Smarty Rookie
Joined: 20 Sep 2008 Posts: 25
|
Posted: Tue Jun 09, 2009 8:20 am Post subject: tag parsing bug |
|
|
Line 3 of the code below works fine, line 4 gives an error - Fatal error: Smarty error: [in cm42.txt line 4]: syntax error: unrecognized tag
The difference between the two lines is just one more addition of the same variable. The error does not occur if the variable name does not contain the _1 in the end.
Unfortunately in my case variable names come from a db so renaming them is not a choice. Any suggestions what should I do?
Code: |
{set var=$foo.baz_bar_1 value=1}
{$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1}
{$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1+$foo.baz_bar_1}
|
Thanks for the help.
SWK |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Jun 09, 2009 8:39 am Post subject: |
|
|
Hi,
increase the pcre.backtrack_limit ini-setting.
HTH |
|
Back to top |
|
SunWuKung Smarty Rookie
Joined: 20 Sep 2008 Posts: 25
|
Posted: Tue Jun 09, 2009 9:05 am Post subject: solved: tag parsing bug |
|
|
That was very fast and useful.
Solved it - I didn't even realise before that there was such a thing in php.ini
Thanks. |
|
Back to top |
|
SunWuKung Smarty Rookie
Joined: 20 Sep 2008 Posts: 25
|
Posted: Tue Jun 09, 2009 10:17 am Post subject: |
|
|
Spoke too soon.
Increasing pcre.backtrack_limit value did allow to use longer tags, but there must be some exponential stuff there, because when I allowed unrealistically large amount I started to run out of the 30 sec when trying to parse this one - 600 characters.
Code: |
{$rv.hun_cm42_3+$rv.hun_cm42_56+$rv.hun_cm42_121+$rv.hun_cm42_156+$rv.hun_cm42_178+$rv.hun_cm42_231+$rv.hun_cm42_242+$rv.hun_cm42_250+$rv.hun_cm42_257+$rv.hun_cm42_263+$rv.hun_cm42_314+$rv.hun_cm42_332}
|
I am looking at the {math} plugin and your rainy-afternoon-boring-compiling-compiler-math-plugin version, but I don't know if that would help me.
- How do I use your compiler version instead of the eval version (my guess is that I remove the function.math.php file and put yours into the plugin)?
- I use security=true, would this work with this setting?
- I have a large number of variables from which template editors may create different equations. Is it possible to define the variables first and only use the equation-assign part of math or the variables must be defined every time inside each math?
Like:
{set var=$v1 value=1}
{set var=$v2 value=2}
{set var=$v3 value=3}
{math equation="v1 + v2" assign=scale.R1}
{math equation="v1 + v3" assign=scale.R2}
{math equation="v2 + v3" assign=scale.R3}
Thanks for the help.
SWK |
|
Back to top |
|
SunWuKung Smarty Rookie
Joined: 20 Sep 2008 Posts: 25
|
Posted: Tue Jun 09, 2009 3:00 pm Post subject: |
|
|
using compiler math doesn't help
compilation dies on the first line -
$_attrs = $compiler->_parse_attrs($tag_args);
I don't see a solution for this.
pls let me know if you find one
Thx.
SWK |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Jun 09, 2009 4:13 pm Post subject: |
|
|
I'd suggest doing any type of non-simple math in a custom plugin. You can then do everything in PHP and keep the template clear of non-presentational clutter. |
|
Back to top |
|
|
|
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
|