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

TASK: Use yield instead of AppendIterator in getObjects #1842

Merged
merged 1 commit into from
Nov 6, 2019

Conversation

albe
Copy link
Member

@albe albe commented Nov 6, 2019

The method docblock stated that it returns a Generator, while in reality for a PackageStorage with patterns, it would fall back to an AppendIterator.
This change instead makes use of yield to return the StorageObjects in a memory-efficient manner.

@albe
Copy link
Member Author

albe commented Nov 6, 2019

Not 100% sure about that removed TODO, but the example code exists since ages and looks as if that's not going to be implemented like that in the foreseeable future.

Copy link
Member

@kdambekalns kdambekalns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good…

Copy link
Member

@kitsunet kitsunet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yes this should target at least 6.0 probably even before...

@albe
Copy link
Member Author

albe commented Nov 6, 2019

Not good really, because getObjectsByPathPattern() already returns a generator - so that's why the AppendIterator was used, to hide having to iterate that result too

@kitsunet
Copy link
Member

kitsunet commented Nov 6, 2019

Not good really, because getObjectsByPathPattern() already returns a generator - so that's why the AppendIterator was used, to hide having to iterate that result too

But we could just do that? Like iterate the inner generators? Seems fine to me

@albe
Copy link
Member Author

albe commented Nov 6, 2019

Good now, but probably needs retargeting to 4.3, or at least 6.0?

@kdambekalns
Copy link
Member

6.0 according to Travis…

@kdambekalns kdambekalns changed the base branch from master to 6.0 November 6, 2019 10:56
@kdambekalns kdambekalns changed the base branch from 6.0 to master November 6, 2019 10:56
@kdambekalns
Copy link
Member

I'll move that to 6.0

@kdambekalns kdambekalns closed this Nov 6, 2019
@kdambekalns kdambekalns reopened this Nov 6, 2019
@kdambekalns kdambekalns changed the base branch from master to 6.0 November 6, 2019 10:59
@kdambekalns kdambekalns closed this Nov 6, 2019
@kdambekalns kdambekalns reopened this Nov 6, 2019
@kdambekalns kdambekalns merged commit 4012392 into 6.0 Nov 6, 2019
@kdambekalns kdambekalns deleted the albe-collection-generator branch November 6, 2019 12:04
skurfuerst added a commit that referenced this pull request Nov 8, 2019
This fixes a regression introduced in #1842:

In this change, a "yield" and a "return" call were introduced in the
same method; so that the early return was not properly executed
because PHP somehow thought this is a fully-suspendable function,
although only one part of the "if"-statement was suspendable.

Related: #1842
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants