php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49607 CachingIterator & DirectoryIterator incorrect behaviour
Submitted: 2009-09-20 14:18 UTC Modified: 2014-07-03 21:39 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: david at grudl dot com Assigned:
Status: Re-Opened Package: SPL related
PHP Version: 5.3.0 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-09-20 14:18 UTC] david at grudl dot com
Description:
------------
Iteration over CachingIterator with DirectoryIterator leads to incorrect results.


Reproduce code:
---------------
// w/o CachingIterator
$dir = new DirectoryIterator(dirname(__FILE__));
foreach ($dir as $val) {
	echo $val;
}

// with CachingIterator
$iterator = new CachingIterator($dir);
foreach ($iterator as $val) {
	echo $val;
}



Expected result:
----------------
It is expected the both code snippets produces the same result:

.
..
anyfile.php

Actual result:
--------------
// w/o CachingIterator:
.
..
anyfile.php

// with CachingIterator:
..
anyfile.php
(empty string)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-30 20:07 UTC] jani@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #49608
 [2009-12-01 13:17 UTC] david at grudl dot com
Please open this bug, it is something different to 49608. This bug is 
not about crash, it is about incorrect iteration results.
 [2014-07-03 21:39 UTC] vrana@php.net
-Status: Not a bug +Status: Re-Opened
 [2014-07-03 21:39 UTC] vrana@php.net
This is still not fixed.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC