Skip to content

Commit

Permalink
minor #50885 [Finder] Fix children condition in ExcludeDirectoryFilte…
Browse files Browse the repository at this point in the history
…rIterator (mvorisek)

This PR was merged into the 5.4 branch.

Discussion
----------

[Finder] Fix children condition in ExcludeDirectoryFilterIterator

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | no
| License       | MIT
| Doc PR        | no

see https://github.com/php/php-src/blob/6091603b5350c1ca0e792a6da604e25e2a0121c8/ext/spl/spl_directory.h#L113

Original `isDir` follow symlinks, so this PR has no effect, but it avoids expensive `isDir` call and makes the condition more correct.

Commits
-------

621f75f969 fix children cond
  • Loading branch information
nicolas-grekas committed Jul 7, 2023
2 parents 96c05af + 0b99334 commit a5d572c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Iterator/ExcludeDirectoryFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(\Iterator $iterator, array $directories)
#[\ReturnTypeWillChange]
public function accept()
{
if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
if (isset($this->excludedDirs[$this->getFilename()]) && $this->hasChildren()) {
return false;
}

Expand Down

0 comments on commit a5d572c

Please sign in to comment.