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

Problem with total property of {section} and {foreach} in nested loop #422

Closed
okamon opened this issue Jan 31, 2018 · 1 comment
Closed

Comments

@okamon
Copy link

okamon commented Jan 31, 2018

The total property of {section} and {foreach} returns different results than v3.1.27.

{section} - Since v3.1.29, this behavior has changed
{foreach} of Smarty 2.x syntax - Since v3.1.28, this behavior has changed

Testcase

{section}

{assign var=samplearr value=[["list" => []],["list" => ["item"]]]}
{foreach $samplearr as $v}
{section name=inner loop=$v.list}
{/section}
loop: {$v@iteration}
inner: {$smarty.section.inner.total}
{/foreach}

{foreach} of Smarty 2.x syntax

{assign var=samplearr value=[["list" => []],["list" => ["item"]]]}
{foreach $samplearr as $v}
{section name=inner loop=$v.list}
{/section}
loop: {$v@iteration}
inner: {$smarty.section.inner.total}
{/foreach}

Actual result

loop: 1
inner: 0
loop: 2
inner: 0

Expected result, up to v3.1.27

loop: 1
inner: 0
loop: 2
inner: 1
uwetews pushed a commit to smarty-php/smarty-phpunit that referenced this issue Mar 21, 2018
uwetews pushed a commit that referenced this issue Mar 21, 2018
… incorrect values if {section}{/section} was called inside

   another loop #422
@uwetews
Copy link
Contributor

uwetews commented Mar 21, 2018

The fix for this problem is now in the master branch and will later be included in the 3.1.32 release

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