summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe <krakjoe@php.net>2018-02-08 10:17:50 +0100
committerJoe <krakjoe@php.net>2018-02-08 10:18:31 +0100
commitab770401e12ee9fe4294d3e560df6d80a2962f35 (patch)
tree9a2a5848d127ede5ccb73b9d48833eb6e736cba2
parent1391a0fa0b41409296efc39c454400073418d9fb (diff)
parent01eafceea12913e710b992fd88e5ab1e23662447 (diff)
downloadphp-git-ab770401e12ee9fe4294d3e560df6d80a2962f35.tar.gz
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fixed bug #74519 strange behavior of AppendIterator
-rw-r--r--NEWS3
-rw-r--r--ext/spl/spl_iterators.c26
-rw-r--r--ext/spl/tests/bug74519.phpt23
3 files changed, 50 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index ab1bc83346..722bb2c472 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,9 @@ PHP NEWS
. Fixed bug #75893 (file_get_contents $http_response_header variable bugged
with opcache). (Nikita)
+- SPL:
+ . Fixed bug #74519 (strange behavior of AppendIterator). (jhdxr)
+
- Standard:
. Fixed bug #75916 (DNS_CAA record results contain garbage). (Mike,
Philip Sharp)
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index 6d087c37d3..47b076300a 100644
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -1796,7 +1796,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)
{
@@ -3392,6 +3391,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)
@@ -3484,7 +3506,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===