Skip to content

Conversation

@klimslim
Copy link
Contributor

…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.

…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.
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.

1 participant