Skip to content

[Finder] no PHP warning on empty directory iteration #19636

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

[Finder] no PHP warning on empty directory iteration #19636

wants to merge 3 commits into from

Conversation

ggottwald
Copy link
Contributor

@ggottwald ggottwald commented Aug 16, 2016

Q A
Branch? 2.8
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR Since RecursiveDirectoryIterator::SKIP_DOTS is set as flag, opendir gets a warning if an empty directory is reached

@@ -137,6 +137,10 @@ public function isRewindable()
return $this->rewindable;
}

if ($this->getPath() === '') {
return $this->rewindable = false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

A test should probably be added to cover this scenario

@fabpot
Copy link
Member

fabpot commented Aug 16, 2016

@ggottwald Can you update the empty title to something relevant? Thanks.

@ggottwald ggottwald changed the title 2.7 [Finder] no PHP warning on empty directory iteration Aug 17, 2016
@ggottwald
Copy link
Contributor Author

https://gist.github.com/ggottwald/07194dc7926ae9093b773ec2297116f3
The changes will fix a warning with HHVM opening an empty directory. Any other ideas resolving this issue? I will also open an issue at HHVM.

@ggottwald
Copy link
Contributor Author

facebook/hhvm#7281

@nicolas-grekas
Copy link
Member

@ggottwald could you please add a test case?

@ggottwald
Copy link
Contributor Author

Sorry for the late response. Until now I was not able to force a catchable warning in the test.
In production I got a errorhandler catching the warning and throws an exception. I didn't find a way to reproduce this in the unittest.
This fix would also only be a workaround of a HHVM bug. Maybe we wait until it's fixed on their side.

@nicolas-grekas
Copy link
Member

👍
Status: reviewed

@@ -137,6 +137,10 @@ public function isRewindable()
return $this->rewindable;
}

if ($this->getPath() === '') {
Copy link
Member

Choose a reason for hiding this comment

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

should be using a Yoda condition: '' === $this->getPath()

@fabpot
Copy link
Member

fabpot commented Sep 14, 2016

Thank you @ggottwald.

fabpot added a commit that referenced this pull request Sep 14, 2016
…twald)

This PR was squashed before being merged into the 2.7 branch (closes #19636).

Discussion
----------

[Finder] no PHP warning on empty directory iteration

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        | Since RecursiveDirectoryIterator::SKIP_DOTS is set as flag, opendir gets a warning if an empty directory is reached

Commits
-------

695e341 [Finder] no PHP warning on empty directory iteration
@fabpot fabpot closed this Sep 14, 2016
This was referenced Oct 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants