[GIT-PULLS] [php-src] PR #23302: Fix GH-23301: nested "yield from" yields a value twice when the middle generator ends with "yield from []"

[email protected] (lazerg)
Newsgroups php.git-pulls
Message-ID <[email protected]>
Pull Request: https://github.com/php/php-src/pull/23302
Author: lazerg

GH-15375's fix made the `DO_INIT` re-advance guard in `zend_generator_resume()` read the flag from the delegating generator rather than from `orig_generator`. That flag is set by `zend_generator_yield_from()` and only ever cleared on `orig_generator`, so on a middle generator it stays set for the rest of its life.

When such a middle generator then delegates to a non-generator iterable (`yield from []`), it still sits on a `ZEND_YIELD_FROM` opline, so it is picked as the delegator even though no new generator link was established, and its stale `DO_INIT` suppresses the resume. The value it yielded last is presented a second time. Twig hits this on every template, since `doDisplay()` always ends with `yield from [];`.

Only treat the generator as the delegator when it actually delegated to another generator (`node.parent` is set); otherwise keep `orig_generator` as before. The GH-15375 tests still pass.

Fixes GH-23301
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.