Calling clear / removeAllItems / removeItemByKey on Magento\Eav\Model\Entity\Collection\AbstractCollection does not remove model from protected _itemsById array #484
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When paginating through EAV collection models (e.g. customers or products) calling the
clear
method does not reset the$_itemsById
protected member. This causes the list of objects referenced in that array to grow exponentially. When working with large collections (e.g. for exports or reports) this can lead to exhausting the amount of memory that a script is allowed to allocate.NOTE: This issue exists in mage1 as well.
I also went ahead and updated
removeAllItems
andremoveItemByKey
.I'd be happy to write a test case but there doesn't appear to be a base one at this time. I'd be helpful if you could point me in the right direction (another similar test case) as this functionality relies on loading entities.
On a side note, whats the difference supposed to be between
clear
andremoveAllItems
?