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

smarty uses iterator_count() on un-rewindable iterator, even if it isn;t needed #443

Closed
quamis opened this issue May 14, 2018 · 3 comments
Closed

Comments

@quamis
Copy link

quamis commented May 14, 2018

In Smarty_Internal_Runtime_Foreach

, the $total variable is computed even when not needed. This might be slow (I use iterators for very large resultsets) and it will also break one-way iterators (iterators that can only be iterated over once, not having a way of implementing the rewind() method).

I have attached a testcase. The rewind function should only get called once in this case
smarty bug testcase.zip

To fix this, please take a look at the attached patch:
Smarty_Internal_Runtime_Foreach.zip

Expected output:
expected

Real output:
real

@uwetews
Copy link
Contributor

uwetews commented May 17, 2018

This is now fixed in the master branch and will later be included in 3.1.33
Please note that the total property is required and will be computed also when you are using some other propteries like last and show

@uwetews uwetews closed this as completed May 17, 2018
@quamis
Copy link
Author

quamis commented May 17, 2018

Any ideea when 3.1.33 will be released?

@uwetews
Copy link
Contributor

uwetews commented May 17, 2018 via email

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