Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Finder] Fix iteration fails with non-rewindable streams #8120

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Finder] Fix iteration for non rewindable stream
  • Loading branch information
alquerci committed May 24, 2013
commit 081675ff7aac471f9c8e3207fa98d680acb29696
9 changes: 8 additions & 1 deletion 9 src/Symfony/Component/Finder/Iterator/FilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ public function rewind()
{
$iterator = $this;
while ($iterator instanceof \OuterIterator) {
if ($iterator->getInnerIterator() instanceof \FilesystemIterator) {
$innerIterator = $iterator->getInnerIterator();

if ($innerIterator instanceof RecursiveDirectoryIterator) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ($innerIterator instanceof RecursiveDirectoryIterator && $innerIterator->isRewindable()) { 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RecursiveDirectoryIterator is a \FilesystemIterator so your fix does not have the same behaviour.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a real "fix" it CS fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stloyd your suggestion is not a CS fix as the suggested code does not have the same behavior than the current code of the PR. Combining both conditions together changes what goes through the elseif

if ($innerIterator->isRewindable()) {
$innerIterator->next();
$innerIterator->rewind();
}
} elseif ($iterator->getInnerIterator() instanceof \FilesystemIterator) {
$iterator->getInnerIterator()->next();
$iterator->getInnerIterator()->rewind();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ public function current()
return new SplFileInfo(parent::current()->getPathname(), $this->getSubPath(), $this->getSubPathname());
}

/**
* Do nothing for non rewindable stream
*/
public function rewind()
{
if (false === $this->isRewindable()) {
return;
}

parent::rewind();
}

/**
* Checks if the stream is rewindable.
*
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.