Bug #68557 [Opn->Csd]: RecursiveDirectoryIterator::seek(0) broken after calling getChildren()

From: Date: Fri, 20 Feb 2015 14:45:27 +0000
Subject: Bug #68557 [Opn->Csd]: RecursiveDirectoryIterator::seek(0) broken after calling getChildren()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190846@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68557&edit=1

 ID:                 68557
 Updated by:         jpauli@php.net
 Reported by:        bschussek at gmail dot com
 Summary:            RecursiveDirectoryIterator::seek(0) broken after
                     calling getChildren()
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            SPL related
 Operating System:   Ubuntu 14.04
 PHP Version:        5.5.19
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c111d1cd701d2720fdf2707640e70cc9ec5cf76e
Log: fix #68557


Previous Comments:
------------------------------------------------------------------------
[2014-12-06 20:06:53] 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.

------------------------------------------------------------------------
[2014-12-06 19:15:31] 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"


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=68557&edit=1


Thread (7 messages)

« previous php.bugs (#190846) next »