diff options
author | Joe <krakjoe@php.net> | 2018-02-08 10:18:45 +0100 |
---|---|---|
committer | Joe <krakjoe@php.net> | 2018-02-08 10:19:15 +0100 |
commit | 748c40867b1b9c98bb64904ec45e1a0720739b4d (patch) | |
tree | 785a39abd152074f76bd09fd5844838b80201b07 | |
parent | 414aaa207cc59c279d3fd5ed83f6b92890e57023 (diff) | |
parent | ab770401e12ee9fe4294d3e560df6d80a2962f35 (diff) | |
download | php-git-748c40867b1b9c98bb64904ec45e1a0720739b4d.tar.gz |
Merge branch 'PHP-7.2'
* PHP-7.2:
Fixed bug #74519 strange behavior of AppendIterator
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/spl/spl_iterators.c | 26 | ||||
-rw-r--r-- | ext/spl/tests/bug74519.phpt | 23 |
3 files changed, 48 insertions, 2 deletions
@@ -153,6 +153,7 @@ PHP NEWS may hide parse error). (Nikita) . Fixed bug #75878 (RecursiveTreeIterator::setPostfix has wrong signature). (cmb) + . Fixed bug #74519 (strange behavior of AppendIterator). (jhdxr) - SQLite3: . Updated bundled libsqlite to 3.22.0. (cmb) diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 0e63acdb38..ee621243e0 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1798,7 +1798,6 @@ SPL_METHOD(dual_it, key) proto mixed ParentIterator::current() proto mixed IteratorIterator::current() proto mixed NoRewindIterator::current() - proto mixed AppendIterator::current() Get the current element value */ SPL_METHOD(dual_it, current) { @@ -3396,6 +3395,29 @@ SPL_METHOD(AppendIterator, append) } } /* }}} */ +/* {{{ proto mixed AppendIterator::current() + Get the current element value */ +SPL_METHOD(AppendIterator, current) +{ + spl_dual_it_object *intern; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis()); + + spl_dual_it_fetch(intern, 1); + if (Z_TYPE(intern->current.data) != IS_UNDEF) { + zval *value = &intern->current.data; + + ZVAL_DEREF(value); + ZVAL_COPY(return_value, value); + } else { + RETURN_NULL(); + } +} /* }}} */ + /* {{{ proto void AppendIterator::rewind() Rewind to the first iterator and rewind the first iterator, too */ SPL_METHOD(AppendIterator, rewind) @@ -3488,7 +3510,7 @@ static const zend_function_entry spl_funcs_AppendIterator[] = { SPL_ME(AppendIterator, rewind, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(AppendIterator, valid, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(dual_it, key, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) - SPL_ME(dual_it, current, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) + SPL_ME(AppendIterator, current, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(AppendIterator, next, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(dual_it, getInnerIterator, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(AppendIterator, getIteratorIndex, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) diff --git a/ext/spl/tests/bug74519.phpt b/ext/spl/tests/bug74519.phpt new file mode 100644 index 0000000000..92efb6378a --- /dev/null +++ b/ext/spl/tests/bug74519.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #74519 strange behavior of AppendIterator +--FILE-- +<?php + +$iterator = new \AppendIterator(); +$events = new \ArrayIterator([1,2,3,4,5]); +$iterator->append($events); + +$events->next(); + +while($iterator->valid()) { + echo $iterator->current(), "\n"; + $iterator->next(); +} +?> +===DONE=== +--EXPECT-- +2 +3 +4 +5 +===DONE=== |