Skip to content

Conversation

@klimslim
Copy link
Contributor

Fix: Populate d_type for shadow directory streams

Problem:
You were right, the shadow PHP extension wasn't correctly setting the d_type (directory entry type) when creating merged directory streams. This could cause tools like RecursiveDirectoryIterator to be less efficient and potentially behave unexpectedly.

Solution:
I've made a couple of adjustments:

  • When dealing with the template directory, I now make sure to store the d_type of each entry.
  • When dealing with the instance directory, I ensure the d_type from the instance entry is stored or updated.
  • When you access the directory stream, I now provide both the name and the correct d_type for each entry.

This should ensure that RecursiveDirectoryIterator and other directory handling functions can work efficiently and correctly by having access to the d_type.

I've also added a new test case (tests/iterator_test.phpt) and the necessary supporting files to specifically cover this scenario.

Testing Limitations:
I encountered some difficulties trying to build the extension and run the tests in my current environment. I kept running into a sandbox error related to calculating file changes after certain commands, particularly those needing sudo access (like installing the PHP extension). I tried a few different approaches to work around this, but unfortunately, I couldn't get past this environmental limitation.

You've asked me to publish the branch so you can test it in your CI environment, and I'm happy to do that.

**Fix: Populate d_type for shadow directory streams**

**Problem:**
You were right, the shadow PHP extension wasn't correctly setting the `d_type` (directory entry type) when creating merged directory streams. This could cause tools like `RecursiveDirectoryIterator` to be less efficient and potentially behave unexpectedly.

**Solution:**
I've made a couple of adjustments:
- When dealing with the template directory, I now make sure to store the `d_type` of each entry.
- When dealing with the instance directory, I ensure the `d_type` from the instance entry is stored or updated.
- When you access the directory stream, I now provide both the name and the correct `d_type` for each entry.

This should ensure that `RecursiveDirectoryIterator` and other directory handling functions can work efficiently and correctly by having access to the `d_type`.

I've also added a new test case (`tests/iterator_test.phpt`) and the necessary supporting files to specifically cover this scenario.

**Testing Limitations:**
I encountered some difficulties trying to build the extension and run the tests in my current environment. I kept running into a sandbox error related to calculating file changes after certain commands, particularly those needing `sudo` access (like installing the PHP extension). I tried a few different approaches to work around this, but unfortunately, I couldn't get past this environmental limitation.

You've asked me to publish the branch so you can test it in your CI environment, and I'm happy to do that.
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