php.net |  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
Votes:5
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
Description:
------------
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:
---------------
<?php
$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:
----------------
libssh.php


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
libssh.php


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-20 15:42 UTC] langemeijer@php.net
-Status: Open +Status: Not a bug
 [2012-06-20 15:42 UTC] langemeijer@php.net
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 
rewind().
 [2013-08-01 22:46 UTC] brett dot thomas at gmail dot com
langemeijer@php.net - 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),
        RecursiveIteratorIterator::CHILD_FIRST
    );
    $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: Fri Apr 19 18:01:28 2024 UTC