if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "o|lzl", &iterator, &flags, &user_caching_it_flags, &mode) == SUCCESS) {
if (instanceof_function(Z_OBJCE_P(iterator), zend_ce_aggregate TSRMLS_CC)) {
zval *aggregate = iterator;
+ zend_restore_error_handling(&error_handling TSRMLS_CC);
zend_call_method_with_0_params(&aggregate, Z_OBJCE_P(aggregate), &Z_OBJCE_P(aggregate)->iterator_funcs.zf_new_iterator, "getiterator", &iterator);
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
inc_refcount = 0;
}
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "o|ll", &iterator, &mode, &flags) == SUCCESS) {
if (instanceof_function(Z_OBJCE_P(iterator), zend_ce_aggregate TSRMLS_CC)) {
zval *aggregate = iterator;
+ zend_restore_error_handling(&error_handling TSRMLS_CC);
zend_call_method_with_0_params(&aggregate, Z_OBJCE_P(aggregate), &Z_OBJCE_P(aggregate)->iterator_funcs.zf_new_iterator, "getiterator", &iterator);
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
inc_refcount = 0;
}
} else {
ce = *pce_cast;
}
if (instanceof_function(ce, zend_ce_aggregate TSRMLS_CC)) {
+ zend_restore_error_handling(&error_handling TSRMLS_CC);
zend_call_method_with_0_params(&zobject, ce, &ce->iterator_funcs.zf_new_iterator, "getiterator", &retval);
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
if (EG(exception)) {
if (retval) {
zval_ptr_dtor(&retval);
--- /dev/null
+--TEST--
+Bug #72122 (IteratorIterator breaks '@' error suppression)
+--FILE--
+<?php
+class CustomIterator implements IteratorAggregate {
+ public function getIterator() {
+ @unlink('/missing/file.txt');
+ return new ArrayIterator(array('item'));
+ }
+}
+
+$obj = new CustomIterator;
+$iterator = new IteratorIterator($obj);
+echo get_class($iterator);
+?>
+--EXPECT--
+IteratorIterator
\ No newline at end of file