|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57378 seek Warning with DirectoryIterator over an sftp stream
Submitted: 2006-11-15 11:03 UTC Modified: 2012-06-20 15:42 UTC
Avg. Score:4.6 ± 0.5
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:4 (80.0%)
From: soenke dot ruempler at northclick dot de Assigned:
Status: Not a bug Package: ssh2 (PECL)
PHP Version: 5.2.0 RC4 OS: Linux
Private report: No CVE-ID: None
 [2006-11-15 11:03 UTC] soenke dot ruempler at northclick dot de
While iteratering over an Directory with SPL RecursiveDirectoryIterator, I get warnings:

PHP Warning:  main(): stream does not support seeking in /home/soenke/tests/libssh.php on line 10

However, the example below seems to work.

Reproduce code:
$session = ssh2_connect('localhost', 22);
ssh2_auth_password($session, 'blub', 'xxxx');
$sftp = ssh2_sftp($session);

$remoteDir = 'ssh2.sftp://' . $sftp;

$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($remoteDir . getcwd()));

foreach ($it as $e) {
   echo $e->getFileName() . "\n";

Expected result:

Actual result:
PHP Warning:  main(): stream does not support seeking in /home/soenke/tests/libssh.php on line 10

Warning: main(): stream does not support seeking in /home/soenke/tests/libssh.php on line 10


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-20 15:42 UTC]
-Status: Open +Status: Not a bug
 [2012-06-20 15:42 UTC]
In newer PHP versions the warning is slightly different. It reads:

FilesystemIterator::rewind(): stream does not support seeking

Which is correct. ssh2 streams don't support seeking, so there can't be a 
 [2013-08-01 22:46 UTC] brett dot thomas at gmail dot com - can you please clarify?  I am running into a similar issue, 
where the iterator actually works, but it still outputs the warning.

Is rewind/seek being called internally?  I'm not calling rewind or seek 
explicitly, yet I'm getting a warning saying something along the lines of streams 
not allowing seeking.

Everything seems ok with using DirectoryIterator on the stream to simply loop 
through the stream, and the idea of supressing the warning seems dirty to me.
 [2022-08-17 16:57 UTC] uuf6429 at gmail dot com
I've just had this same problem in PHP 8.1, in principle the code looks like so:

    $path = 'ftps://user:pass@host:21/htdocs';
    $iterator = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
    $items = iterator_to_array($iterator);    // <- error thrown here

Similar to the previous comment, I don't understand what's wrong or where rewind() is being triggered.

Additionally, I don't know about ssh, but this is just listing files from ftp, which in my view, does not relate to ssh.

On top of this, I also tried using `ftp://` instead and the same problem happened.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 13 06:01:27 2024 UTC