mirror of
https://github.com/php/php-src.git
synced 2025-08-17 22:48:57 +02:00
fix bug #75173 incorrect behavior of AppendIterator::append in foreach loop
This commit is contained in:
parent
9aa6898b9b
commit
3e11b7fc21
3 changed files with 23 additions and 1 deletions
4
NEWS
4
NEWS
|
@ -33,6 +33,10 @@ PHP NEWS
|
|||
. Fixed bug #74631 (PDO_PCO with PHP-FPM: OCI environment initialized
|
||||
before PHP-FPM sets it up). (Ingmar Runge)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #75173 (incorrect behavior of AppendIterator::append in foreach loop).
|
||||
(jhdxr)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #75097 (gethostname fails if your host name is 64 chars long). (Andrea)
|
||||
|
||||
|
|
|
@ -3384,7 +3384,7 @@ SPL_METHOD(AppendIterator, append)
|
|||
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "O", &it, zend_ce_iterator) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
if (intern->u.append.iterator->funcs->valid(intern->u.append.iterator) == SUCCESS) {
|
||||
if (intern->u.append.iterator->funcs->valid(intern->u.append.iterator) == SUCCESS && spl_dual_it_valid(intern) != SUCCESS) {
|
||||
spl_array_iterator_append(&intern->u.append.zarrayit, it);
|
||||
intern->u.append.iterator->funcs->move_forward(intern->u.append.iterator);
|
||||
}else{
|
||||
|
|
18
ext/spl/tests/bug75173.phpt
Normal file
18
ext/spl/tests/bug75173.phpt
Normal file
|
@ -0,0 +1,18 @@
|
|||
--TEST--
|
||||
Bug #75173 incorrect behavior of AppendIterator::append in foreach loop
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$it = new \AppendIterator();
|
||||
$it->append(new ArrayIterator(['foo']));
|
||||
|
||||
foreach ($it as $item) {
|
||||
var_dump($item);
|
||||
|
||||
if ('foo' === $item) {
|
||||
$it->append(new ArrayIterator(['bar']));
|
||||
}
|
||||
}
|
||||
--EXPECT--
|
||||
string(3) "foo"
|
||||
string(3) "bar"
|
Loading…
Add table
Add a link
Reference in a new issue