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

3.1.30 Regression: {if $value = array_shift($array)} #291

Closed
rvock opened this issue Sep 13, 2016 · 1 comment
Closed

3.1.30 Regression: {if $value = array_shift($array)} #291

rvock opened this issue Sep 13, 2016 · 1 comment

Comments

@rvock
Copy link

rvock commented Sep 13, 2016

With the change to 3.1.30 the array_shift will be executed twice:

{$array = [1, 2]}
{if $value = array_shift($array)}
Count: {count($array)}
{/if}

This will output 0 instead of 1.

The generated code looks something like this:

$_smarty_tpl->_assignInScope('array', array(1,2));
$_smarty_tpl->_assignInScope('value', array_shift($_smarty_tpl->tpl_vars['array']->value));
if (array_shift($_smarty_tpl->tpl_vars['array']->value)) {?>Count: <?php echo Vierwd\VierwdSmarty\View\clean(count($_smarty_tpl->tpl_vars['array']->value),$_smarty_tpl);
}

Version 3.1.29 worked fine and generated this code:

$_smarty_tpl->tpl_vars['array'] = new Smarty_Variable(array(1,2), null);
$_smarty_tpl->ext->_updateScope->updateScope($_smarty_tpl, 'array', 0);
if (!isset($_smarty_tpl->tpl_vars['value'])) $_smarty_tpl->tpl_vars['value'] = new Smarty_Variable(null);if ($_smarty_tpl->tpl_vars['value']->value = array_shift($_smarty_tpl->tpl_vars['array']->value)) {?>Count: <?php echo Vierwd\VierwdSmarty\View\clean(smir(count($_smarty_tpl->tpl_vars['array']->value)),$_smarty_tpl);
}
uwetews added a commit that referenced this issue Sep 15, 2016
…alue = array_shift($array)} the function got called twice #291
@uwetews
Copy link
Contributor

uwetews commented Sep 15, 2016

This is now fixed in the master branch.

@uwetews uwetews closed this as completed Sep 15, 2016
uwetews added a commit that referenced this issue Sep 15, 2016
…alue = array_shift($array)} the function got called twice #291
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