php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72122 IteratorIterator breaks '@' error suppression
Submitted: 2016-04-28 14:32 UTC Modified: 2016-07-12 08:28 UTC
From: kinglozzer at gmail dot com Assigned: jpauli
Status: Closed Package: SPL related
PHP Version: 5.5.34 OS: OS X
Private report: No CVE-ID:
 [2016-04-28 14:32 UTC] kinglozzer at gmail dot com
Description:
------------
The '@' error suppression operator appears to not work correctly when wrapped by IteratorIterator. The issue occurs when an error is triggered (and supposedly suppressed) in getIterator() in the inner iterator - an InvalidArgumentException is thrown instead.

I’ve not tested this in any great detail, or with other iterator types (apologies, time is tight at the moment).

Test script:
---------------
<?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 'done';

Expected result:
----------------
Text 'done' should be shown

Actual result:
--------------
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'unlink(/missing/file.txt): No such file or directory'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-12 08:28 UTC] jpauli@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: jpauli
 [2016-07-12 08:28 UTC] jpauli@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC