Skip to content
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

[Finder] Fix ignoring of unreadable dirs in the RecursiveDirectoryIterator #10772

Merged
merged 1 commit into from
Apr 24, 2014

Conversation

jakzal
Copy link
Contributor

@jakzal jakzal commented Apr 23, 2014

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #10747
License MIT
Doc PR -

\RecursiveDirectoryIterator::getChildren() creates an instance of the current (overloaded) class with default constructor arguments. Therefore the ignoreUnreadableDirs is not passed to the child directories as @marcj suggested in #10747.

My fix relies on PHP's ability to modify private properties in objects of the same class. My reasoning behind choosing this approach, instead of using a setter, is that it's an internal detail which doesn't need to be part of a public interface.

Unfortunately, I can't really cover this case by tests.

return parent::getChildren();
$children = parent::getChildren();

if ($children instanceof RecursiveDirectoryIterator) {
Copy link
Member

Choose a reason for hiding this comment

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

maybe instanceof self which is more obvious

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea 👍

@Tobion
Copy link
Member

Tobion commented Apr 23, 2014

Can you not add a test just as #10747 demonstrates?

@jakzal
Copy link
Contributor Author

jakzal commented Apr 23, 2014

How would I make a cleanup after test if I revoked permissions to myself?

@Tobion
Copy link
Member

Tobion commented Apr 23, 2014

Good question ;)

@fabpot
Copy link
Member

fabpot commented Apr 24, 2014

Thank you @jakzal.

@fabpot fabpot merged commit 1346641 into symfony:2.3 Apr 24, 2014
fabpot added a commit that referenced this pull request Apr 24, 2014
…irectoryIterator (jakzal)

This PR was merged into the 2.3 branch.

Discussion
----------

[Finder] Fix ignoring of unreadable dirs in the RecursiveDirectoryIterator

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #10747
| License       | MIT
| Doc PR        | -

`\RecursiveDirectoryIterator::getChildren()` creates an instance of the current (overloaded) class with default constructor arguments. Therefore the `ignoreUnreadableDirs` is not passed to the child directories as @marcj suggested in #10747.

My fix relies on PHP's ability to modify private properties in objects of the same class. My reasoning behind choosing this approach, instead of using a setter, is that it's an internal detail which doesn't need to be part of a public interface.

Unfortunately, I can't really cover this case by tests.

Commits
-------

1346641 [Finder] Fix ignoring of unreadable dirs in the RecursiveDirectoryIterator.
@jakzal jakzal deleted the recursive-dir-iterator-fix branch April 24, 2014 08:01
@hice3000
Copy link
Contributor

hice3000 commented May 5, 2014

Maybe someone should add an "incomplete" note to the according test so that we don't forget there is something missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants