nextras / orm

Orm with clean object design, smart relationship loading and powerful collections.
https://nextras.org/orm
MIT License
309 stars 59 forks source link

Iterator_count() does not preserve iteration position. #125

Closed hrach closed 9 years ago

hrach commented 9 years ago

@johnCourtier: Hi, according to http://php.net/manual/en/function.iterator-count.php it is not guaranteed, that current position of iterator is retained. This could lead to some issues (eg. if called in foreach cycle, not every element can be actually iterated). Can you use "count" function instead? Also applies to other occurences of "iterator_count". https://github.com/nextras/orm/commit/a55a99e4bf3cc80fb9a4124eb540e815603e07af#commitcomment-13737286

hrach commented 9 years ago

I was able to reproduce it only in one usecase, which has to be fixed differently than replacing iterator_count, sice setDataIndex always reseted the position in relationship iterator.