smarty-php / smarty-php/smarty
Compilation error ?
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.3k
- Forks
- 709
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I had difficulty identifying a problem in a template. After reading the documentation I wonder if the behavior is normal or faulty.
$WXO_PRODUCT_CROSS and $WXO_PRODUCT_UP both have the value "".
The following code should not produce HTML output but it does. My error is a missing $ in the first condition.
{if isset($WXO_PRODUCT_CROSS) && WXO_PRODUCT_CROSS ne ''}
{if isset($WXO_PRODUCT_CROSS) && $WXO_PRODUCT_CROSS ne ''}
<a href="#tab-articles-complementaires">{t}Additional articles{/t}</a>
{/if}
{if isset($WXO_PRODUCT_UP) && $WXO_PRODUCT_UP ne ''}
<a href="#tab-articles-similaires">{t}Similar articles{/t}</a
{/if}
{$WXO_PRODUCT_CROSS}
{/if}
The resulting code compiled by Smarty is:
<?php if ((isset($_smarty_tpl->tpl_vars['WXO_PRODUCT_CROSS']->value)) && 'WXO_PRODUCT_CROSS' != '') {?>
instead of
<?php if ((isset($_smarty_tpl->tpl_vars['WXO_PRODUCT_CROSS']->value)) && $_smarty_tpl->tpl_vars['WXO_PRODUCT_CROSS']->value != '') {?>
Is it normal for "WXO_PRODUCT_CROSS" to be interpreted as a string instead of causing a compilation error?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Smarty template shown in the issue and inspect the generated PHP condition. Compare the behavior of the missing-$ expression with the expected compilation output, then check whether existing parser or compiler tests cover this case. Done means the behavior is confirmed and, if faulty, covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100