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.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Sep 16 14:01:28 2019 UTC