Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error ? #917

Open
lkppo opened this issue Nov 23, 2023 · 2 comments
Open

Compilation error ? #917

lkppo opened this issue Nov 23, 2023 · 2 comments

Comments

@lkppo
Copy link

lkppo commented Nov 23, 2023

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?

@wisskid
Copy link
Contributor

wisskid commented Nov 23, 2023

Interesting. This looks like the PHP bareword behavior that has been removed in php8.0. I never noticed it in Smarty before. Will have to test first. What smarty version and what php version are you using?

@lkppo
Copy link
Author

lkppo commented Nov 23, 2023

I use PHP 8.0.1 and Smarty 3.1.48.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants