From: Nikita Popov Date: Tue, 7 Jul 2020 07:04:20 +0000 (+0200) Subject: Don't allow separation in CallbackFilterIterator X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=df8119d3e1228ea0dcc14f18027e2d57de76d28e;p=php Don't allow separation in CallbackFilterIterator As the name might suggest, this is a *filter* iterator. If you want to have a *map* iterator, write one, or use a generator. --- diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 1656ef1f77..9e4ed5036f 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1785,7 +1785,7 @@ PHP_METHOD(CallbackFilterIterator, accept) fci->retval = return_value; fci->param_count = 3; fci->params = params; - fci->no_separation = 0; + fci->no_separation = 1; if (zend_call_function(fci, fcc) != SUCCESS || Z_ISUNDEF_P(return_value)) { RETURN_FALSE; @@ -1794,10 +1794,6 @@ PHP_METHOD(CallbackFilterIterator, accept) if (EG(exception)) { RETURN_THROWS(); } - - /* zend_call_function may change args to IS_REF */ - ZVAL_COPY_VALUE(&intern->current.data, ¶ms[0]); - ZVAL_COPY_VALUE(&intern->current.key, ¶ms[1]); } /* }}} */ diff --git a/ext/spl/tests/bug72051.phpt b/ext/spl/tests/bug72051.phpt index b0fe05169a..42cc1ea833 100644 --- a/ext/spl/tests/bug72051.phpt +++ b/ext/spl/tests/bug72051.phpt @@ -17,10 +17,10 @@ $data = $callbackTest->current(); $callbackTest->next(); print_r($data); ?> ---EXPECT-- +--EXPECTF-- +Warning: {closure}(): Argument #1 ($current) must be passed by reference, value given in %s on line %d Array ( [0] => 1 [1] => 2 - [message] => Test message )