Skip to content

Comments

Ensure that getAvailablePaths respects the maxDepth of the file iterator#135

Merged
LukeTowers merged 2 commits intodevelopfrom
wip/child-theme-autodatasource-caching
Dec 12, 2022
Merged

Ensure that getAvailablePaths respects the maxDepth of the file iterator#135
LukeTowers merged 2 commits intodevelopfrom
wip/child-theme-autodatasource-caching

Conversation

@jaxwilko
Copy link
Member

@jaxwilko jaxwilko commented Dec 9, 2022

This PR fixes an issue brought to light by wintercms/winter#791.

When FileDatasource::getAvailablePaths() is called, it does not respect the same maxDepth setting that is set in FileDatasource::select() meaning that the reported paths differ from the selectable paths.

This PR adds the setMaxDepth() call on the iterator used in getAvailablePaths() and sets a property for maxDepth to remove magic numbers and allow for custom extensions.

@what-the-diff
Copy link

what-the-diff bot commented Dec 9, 2022

  • Added a new property to the class: $maxDepth
  • Changed setMaxDepth() from 1 to use max depth instead of hardcoded value
  • Updated getAvailablePaths() method so that it uses max depth +1 for RecursiveIteratorIterator::setMaxDepth(). This is because we want all subdirectories, not just one level down (which would be 0).

@LukeTowers LukeTowers changed the title Added fix to ensure that getAvailablePaths respects the maxDepth of the file iterator Ensure that getAvailablePaths respects the maxDepth of the file iterator Dec 12, 2022
@LukeTowers LukeTowers merged commit b693175 into develop Dec 12, 2022
@LukeTowers LukeTowers deleted the wip/child-theme-autodatasource-caching branch December 12, 2022 16:32
LukeTowers pushed a commit that referenced this pull request May 29, 2023
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.

2 participants