?? ??? ????, PHP 7.4.6
+- Core:
+ . Fixed bug #78434 (Generator yields no items after valid() call). (Nikita)
+
- DOM:
. Fixed bug #78221 (DOMNode::normalize() doesn't remove empty text nodes).
(cmb)
--- /dev/null
+--TEST--
+Bug #78434: Generator skips first item after valid() call
+--FILE--
+<?php
+
+$function = function () {
+ yield 0;
+};
+
+$wrapper = function () use ($function) {
+ $generator = $function();
+ $generator->valid();
+ yield from $generator;
+
+ $generator = $function();
+ $generator->valid();
+ yield from $generator;
+};
+
+foreach ($wrapper() as $value) {
+ echo $value, "\n";
+}
+
+?>
+--EXPECT--
+0
+0
generator->node.parent = from;
zend_generator_get_current(generator);
GC_DELREF(&from->std);
+ generator->flags |= ZEND_GENERATOR_DO_INIT;
}
ZEND_API zend_generator *zend_generator_update_current(zend_generator *generator, zend_generator *leaf)
if (UNEXPECTED((orig_generator->flags & ZEND_GENERATOR_DO_INIT) != 0 && !Z_ISUNDEF(generator->value))) {
/* We must not advance Generator if we yield from a Generator being currently run */
+ orig_generator->flags &= ~ZEND_GENERATOR_DO_INIT;
return;
}
goto try_again;
}
}
+
+ orig_generator->flags &= ~ZEND_GENERATOR_DO_INIT;
}
/* }}} */
static inline void zend_generator_ensure_initialized(zend_generator *generator) /* {{{ */
{
if (UNEXPECTED(Z_TYPE(generator->value) == IS_UNDEF) && EXPECTED(generator->execute_data) && EXPECTED(generator->node.parent == NULL)) {
- generator->flags |= ZEND_GENERATOR_DO_INIT;
zend_generator_resume(generator);
- generator->flags &= ~ZEND_GENERATOR_DO_INIT;
generator->flags |= ZEND_GENERATOR_AT_FIRST_YIELD;
}
}