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

Undefined variables #391

Closed
Stadly opened this issue Oct 9, 2017 · 1 comment
Closed

Undefined variables #391

Stadly opened this issue Oct 9, 2017 · 1 comment

Comments

@Stadly
Copy link

Stadly commented Oct 9, 2017

Consider the following smarty template.

{"{if false}"|cat:{'foo'}|cat:"{/if}"}

It is compiled into the following php template.

ob_start();
if (false) {
$_prefixVariable1=ob_get_clean();
ob_start();
echo 'foo';
$_prefixVariable2=ob_get_clean();
ob_start();
}
$_prefixVariable3=ob_get_clean();
echo (($_prefixVariable1).($_prefixVariable2)).($_prefixVariable3);
}

When the compiled template is run, it generates two errors: Notice: Undefined variable: _prefixVariable1 and Notice: Undefined variable: _prefixVariable2.

Note: Obviously, the template is not very useful, since I've tried to make a minimal example to show the issue. But I ran into the issue when using some similar logic in a template that was actually useful.

@uwetews
Copy link
Contributor

uwetews commented Oct 12, 2017

The master branch has been updated to throw a compiler exception for this condition.

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