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

From: Date: Sat, 15 Aug 2026 21:25:13 +0000
Subject: [php-src] PR #23302: Fix GH-23301: nested "yield from" yields a value twice when the middle generator ends with "yield from []"
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-37906@lists.php.net to get a copy of this message
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

« previous php.git-pulls (#37906) next »