Fix: Correct child entry type in SPL iterators and add comprehensive …#61
Open
klimslim wants to merge 1 commit intosugarcrm:masterfrom
Open
Fix: Correct child entry type in SPL iterators and add comprehensive …#61klimslim wants to merge 1 commit intosugarcrm:masterfrom
klimslim wants to merge 1 commit intosugarcrm:masterfrom
Conversation
…test
This commit introduces two main improvements:
1. **Enhanced `d_type` Propagation:**
The shadow directory stream wrapper (`shadow_dirstream_read` and
`shadow_dir_opener`) has been updated to correctly propagate the
`d_type` (directory entry type) from the underlying filesystem.
This ensures that SPL iterators receive accurate type information
(file, directory, etc.) for child entries, improving reliability
and potentially performance by reducing reliance on stat() fallbacks.
This addresses the core of the issue where files might be iterated
as directories or vice-versa.
2. **New Test for Iterator Child Types (`tests/iterator_child_types.phpt`):**
A new test case has been added to specifically verify the type
correctness of child entries during iteration with shadow enabled.
This test uses `RecursiveIteratorIterator::LEAVES_ONLY` and confirms
that files and directories within the shadowed structure are correctly
identified.
The existing test `tests/iterator_test.phpt` continues to fail due to an
issue with `RecursiveIteratorIterator::SELF_FIRST` mode. When this mode
is used, the first item yielded (representing the directory itself)
incorrectly takes on the path and type of its first child. This appears
to be a complex interaction with SPL's internal mechanisms for populating
SplFileInfo objects in this context and is documented as a known issue
requiring separate, dedicated investigation.
The changes in this commit significantly improve the robustness of SPL
iterator interactions with the shadow extension for child entries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…test
This commit introduces two main improvements:
Enhanced
d_typePropagation: The shadow directory stream wrapper (shadow_dirstream_readandshadow_dir_opener) has been updated to correctly propagate thed_type(directory entry type) from the underlying filesystem. This ensures that SPL iterators receive accurate type information (file, directory, etc.) for child entries, improving reliability and potentially performance by reducing reliance on stat() fallbacks. This addresses the core of the issue where files might be iterated as directories or vice-versa.New Test for Iterator Child Types (
tests/iterator_child_types.phpt): A new test case has been added to specifically verify the type correctness of child entries during iteration with shadow enabled. This test usesRecursiveIteratorIterator::LEAVES_ONLYand confirms that files and directories within the shadowed structure are correctly identified.The existing test
tests/iterator_test.phptcontinues to fail due to an issue withRecursiveIteratorIterator::SELF_FIRSTmode. When this mode is used, the first item yielded (representing the directory itself) incorrectly takes on the path and type of its first child. This appears to be a complex interaction with SPL's internal mechanisms for populating SplFileInfo objects in this context and is documented as a known issue requiring separate, dedicated investigation.The changes in this commit significantly improve the robustness of SPL iterator interactions with the shadow extension for child entries.