|  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.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Feb 23 07:01:25 2020 UTC