-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.0][Finder] Iteration fails with non-rewindable streams #3585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is already an issue when trying to use a FilesystemIterator with the ftp stream wrapper. So maybe the fix is to remove this example from the docs and file the ticket to PHP. |
Just add : <?php
if (false === stream_is_local($dir)) {
$iterator = new \NoRewindIterator($iterator);
} |
I tried adding that after the following lines in
But it looks like one of those iterators depends on rewinding. The initial FTP connection succeeds, but then it just lists the first file twice and errors out again with the same error message. |
adding this just before returning the iterator does not work either. It just always returns an empty result. |
Work for me with : https://gist.github.com/2028995 <?php
use Symfony\Component\Finder\Finder;
$finder = new Finder();
$finder->files()->in('ftp://ftp.mozilla.org/');
foreach ($finder as $file) {
var_dump($file);
} but not sure if |
It does not work in all cases, for instance if you add a Catchable fatal error: Argument 1 passed to Symfony\Component\Finder\Iterator\DepthRangeFilterIterator::__construct() must be an instance of RecursiveIteratorIterator, instance of NoRewindIterator given, called in /Users/fabien/work/symfony/git/symfony/src/Symfony/Component/Finder/Finder.php on line 474 |
Anyway the I see two solutions her :
|
Here is the first stage of my implementation of It works with filters ( |
see #4335 |
This PR was squashed before being merged into the 2.1 branch (closes Discussion ---------- [Finder] Fix iteration fails with non-rewindable streams <table> <tr> <th>Q</th><th>A</th> </tr> <tr> <td>Bug fix?</td><td>yes</td> </tr> <tr> <td>New feature?</td><td>no</td> </tr> <tr> <td>BC breaks?</td><td>no</td> </tr> <tr> <td>Deprecations?</td><td>no</td> </tr> <tr> <td>Tests pass?</td><td>yes</td> </tr> <tr> <td>Fixed tickets</td><td>#3585, #7834</td> </tr> <tr> <td>License?</td><td>MIT</td> </tr> </table> - [x] Add a good detection of non seekable stream - [x] Add some unit tests But the iteration under ftp stream still not work properly. Edit: need tests for that. Commits ------- 169c0b9 [Finder] Fix iteration fails with non-rewindable streams
Commits ------- 3eb67fc [2.1][Component][Finder] $this->current() fix Discussion ---------- [2.1][Component][Finder] $this->current() fix Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: [](http://travis-ci.org/gajdaw/symfony) Fixes the following tickets: - Todo: - License of the code: MIT One method to resolve `->in("ftp://...")` problem is to create `RecursiveDirectoryFtpIterator`. (Details: [issue 3585](symfony#3585)) I think that all filters should access the information about current item calling `current()` or `getInnerIterator()`. Otherwise it will not work if we replace `RecursiveDirectoryIterator` with ftp iterator inside `Finder`. I'm not sure if that should go to 2.0 or 2.1 branch. --------------------------------------------------------------------------- by travisbot at 2012-05-19T09:20:19Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1373361) (merged 9f247921 into 58b9245). --------------------------------------------------------------------------- by gajdaw at 2012-05-19T10:51:10Z Probably it should go to master branch, because it improves commit done to master: symfony@f2fea97 --------------------------------------------------------------------------- by travisbot at 2012-05-19T11:26:14Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1373982) (merged f9d1db8c into 58b9245). --------------------------------------------------------------------------- by travisbot at 2012-05-19T11:51:25Z This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1374031) (merged f1b4b4f7 into 58b9245). --------------------------------------------------------------------------- by travisbot at 2012-05-19T12:48:17Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1374303) (merged b6d073da into 58b9245). --------------------------------------------------------------------------- by travisbot at 2012-05-19T13:28:18Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1374568) (merged fd144c96 into 58b9245). --------------------------------------------------------------------------- by travisbot at 2012-05-19T13:35:38Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1374609) (merged 89a8d851 into 58b9245). --------------------------------------------------------------------------- by travisbot at 2012-05-21T04:31:46Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1385764) (merged 0d5b8322 into 58b9245). --------------------------------------------------------------------------- by travisbot at 2012-05-21T07:21:56Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1386545) (merged 3eb67fc into 1407f11). --------------------------------------------------------------------------- by stof at 2012-06-09T13:24:14Z seems good
Commits ------- 3e1d3b8 [2.1][Component][Finder] $this->current() fix Discussion ---------- [2.1][Component][Finder] $this->current() fix Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: [](http://travis-ci.org/gajdaw/symfony) Fixes the following tickets: - Todo: - License of the code: MIT One method to resolve `->in("ftp://...")` problem is to create `RecursiveDirectoryFtpIterator`. (Details: [issue 3585](symfony/symfony#3585)) I think that all filters should access the information about current item calling `current()` or `getInnerIterator()`. Otherwise it will not work if we replace `RecursiveDirectoryIterator` with ftp iterator inside `Finder`. I'm not sure if that should go to 2.0 or 2.1 branch. --------------------------------------------------------------------------- by travisbot at 2012-05-19T09:20:19Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1373361) (merged 9f247921 into 58b92453). --------------------------------------------------------------------------- by gajdaw at 2012-05-19T10:51:10Z Probably it should go to master branch, because it improves commit done to master: symfony/symfony@e553c49 --------------------------------------------------------------------------- by travisbot at 2012-05-19T11:26:14Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1373982) (merged f9d1db8c into 58b92453). --------------------------------------------------------------------------- by travisbot at 2012-05-19T11:51:25Z This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1374031) (merged f1b4b4f7 into 58b92453). --------------------------------------------------------------------------- by travisbot at 2012-05-19T12:48:17Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1374303) (merged b6d073da into 58b92453). --------------------------------------------------------------------------- by travisbot at 2012-05-19T13:28:18Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1374568) (merged fd144c96 into 58b92453). --------------------------------------------------------------------------- by travisbot at 2012-05-19T13:35:38Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1374609) (merged 89a8d851 into 58b92453). --------------------------------------------------------------------------- by travisbot at 2012-05-21T04:31:46Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1385764) (merged 0d5b8322 into 58b92453). --------------------------------------------------------------------------- by travisbot at 2012-05-21T07:21:56Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1386545) (merged 3e1d3b8 into 1407f112). --------------------------------------------------------------------------- by stof at 2012-06-09T13:24:14Z seems good
The finder docs mention iterating over an FTP stream, like so:
Turns out, this does not work. It errors out with:
Other stream wrappers may be affected as well.
Looks like @krachot already mentioned this somewhere a year ago.
The text was updated successfully, but these errors were encountered: