Fix GH-15375: nested "yield from" skips items after valid()/next() - #22640
Fix GH-15375: nested "yield from" skips items after valid()/next()#22640iliaal wants to merge 1 commit into
Conversation
The DO_INIT guard in zend_generator_resume() that avoids re-advancing an already-primed delegate read the flag on orig_generator, but in a nested "yield from" chain the fresh delegation is established by a middle generator rather than the outermost consumer. Track the delegating generator through the resume loop and check its DO_INIT, so a primed inner generator reached through two "yield from" levels yields its current value once instead of skipping it. Fixes phpGH-15375
|
Is it possible that this commit broke the symfony demo app? if you have a look at the nightly benchmark logs (https://github.com/php/php-src/actions/runs/31758646923/job/94639986302#step:16:20969), it will be visible that the end of the HTML is duplicated for some reason: even though the template properly has them: https://github.com/symfony/demo/blob/v2.8.0/templates/base.html.twig#L140 I "bisected" the PHP commits one by one and this was the first commit where the benchmark broke. |
|
Is it possible to revert this change until the fix is merged? |
|
If there is a real-world impact (in fact there is) we should revert this and apply #23302 |
I reviewed the #23302 PR and it looks correct and is pretty trivial (1 line fix) which can be safely merged imho, if we don't merge in the next few days, then I'd say reverting this change is the way to go... |
Nested
yield fromdrops the inner generator's current value on the second and later delegations when it was primed viavalid()/next(). TheZEND_GENERATOR_DO_INITguard inzend_generator_resume()reads the flag onorig_generator, but in a nested chain the fresh delegation is established by the middle generator, whose flag it never checks. Track and check the delegating generator instead.Fixes #15375