php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68557 RecursiveDirectoryIterator::seek(0) broken after calling getChildren()
Submitted: 2014-12-06 19:15 UTC Modified: 2015-04-28 17:05 UTC
From: bschussek at gmail dot com Assigned: jpauli (profile)
Status: Closed Package: SPL related
PHP Version: 5.5.19 OS: Ubuntu 14.04
Private report: No CVE-ID: None
 [2014-12-06 19:15 UTC] bschussek at gmail dot com
Description:
------------
After calling RecursiveDirectoryIterator::getChildren(), RecursiveDirectoryIterator::seek(0) has no effect.

Test script:
---------------
<?php

mkdir(__DIR__.'/temp');
mkdir(__DIR__.'/temp/a');
mkdir(__DIR__.'/temp/b');

$iterator = new \RecursiveDirectoryIterator(__DIR__.'/temp', \RecursiveDirectoryIterator::SKIP_DOTS);

$iterator->seek(0);
var_dump($iterator->key());

$iterator->seek(1);
var_dump($iterator->key());

$iterator->getChildren();

$iterator->seek(0);
var_dump($iterator->key());

$iterator->seek(1);
var_dump($iterator->key());

rmdir(__DIR__.'/temp/a');
rmdir(__DIR__.'/temp/b');
rmdir(__DIR__.'/temp');


Expected result:
----------------
string(7) "<snip>/temp/b"
string(7) "<snip>/temp/a"
string(7) "<snip>/temp/b"
string(7) "<snip>/temp/a"

Actual result:
--------------
string(7) "<snip>/temp/b"
string(7) "<snip>/temp/a"
string(7) "<snip>/temp/a"
string(7) "<snip>/temp/a"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-06 20:06 UTC] bschussek at gmail dot com
I did some more testing. The same bugs appears for DirectoryIterator:

---------------
<?php

mkdir(__DIR__.'/temp');
mkdir(__DIR__.'/temp/a');
mkdir(__DIR__.'/temp/b');

$iterator = new DirectoryIterator(__DIR__.'/temp');

$iterator->seek(0);
var_dump($iterator->current()->getPathname());

$iterator->seek(1);
var_dump($iterator->current()->getPathname());

$iterator->seek(0);
var_dump($iterator->current()->getPathname());

$iterator->seek(1);
var_dump($iterator->current()->getPathname());

rmdir(__DIR__.'/temp/a');
rmdir(__DIR__.'/temp/b');
rmdir(__DIR__.'/temp');
---------------

Neither rewind() nor seek(0) works.
 [2015-02-20 14:45 UTC] jpauli@php.net
Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c111d1cd701d2720fdf2707640e70cc9ec5cf76e
Log: fix #68557
 [2015-02-20 14:45 UTC] jpauli@php.net
-Status: Open +Status: Closed
 [2015-02-20 14:45 UTC] jpauli@php.net
Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c111d1cd701d2720fdf2707640e70cc9ec5cf76e
Log: fix #68557
 [2015-02-20 14:46 UTC] jpauli@php.net
Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c111d1cd701d2720fdf2707640e70cc9ec5cf76e
Log: fix #68557
 [2015-02-20 14:46 UTC] jpauli@php.net
-Status: Closed +Status: Feedback
 [2015-02-20 14:46 UTC] jpauli@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.5-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2015-03-01 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2015-04-28 11:55 UTC] bschussek at gmail dot com
Confirmed fixed under PHP 5.5.22. Thanks!
 [2015-04-28 17:05 UTC] requinix@php.net
-Status: No Feedback +Status: Closed -Assigned To: +Assigned To: jpauli
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC