-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Conversation
return parent::getChildren(); | ||
$children = parent::getChildren(); | ||
|
||
if ($children instanceof RecursiveDirectoryIterator) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea 👍
Can you not add a test just as #10747 demonstrates? |
How would I make a cleanup after test if I revoked permissions to myself? |
Good question ;) |
Thank you @jakzal. |
…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.
Maybe someone should add an "incomplete" note to the according test so that we don't forget there is something missing. |
\RecursiveDirectoryIterator::getChildren()
creates an instance of the current (overloaded) class with default constructor arguments. Therefore theignoreUnreadableDirs
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.