Browse Source
fix bug #75173 incorrect behavior of AppendIterator::append in foreach loop
pull/2750/head
jhdxr
8 years ago
committed by
Joe Watkins
No known key found for this signature in database
GPG Key ID: F9BA0ADA31CBD89E
3 changed files with
23 additions and
1 deletions
-
NEWS
-
ext/spl/spl_iterators.c
-
ext/spl/tests/bug75173.phpt
|
|
|
@ -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{ |
|
|
|
|
|
|
|
@ -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" |