Commit 4b32a8c
committed
Fix(shadow): Correctly report entry types and resolve build failure
This commit amends the previous attempt to fix SPL iterator type reporting.
Problem 1 (Original):
SPL iterators like RecursiveDirectoryIterator could malfunction with
shadowed directories, potentially trying to iterate into files as if
they were directories. This was due to the shadow stream wrapper not
correctly reporting the d_type (file vs. directory) for entries.
Solution 1 (Original, still active):
1. Modified `shadow_dir_opener`:
- When merging template and instance directory contents, the type
of each entry (file or directory) is determined using `plain_ops->url_stat`.
- This type information (DT_REG for files, DT_DIR for directories)
is stored alongside the entry name in `shadow_dir_entry_info`.
2. Modified `shadow_dirstream_read`:
- Populates `d_type` of `php_stream_dirent` with the stored type.
Problem 2 (Build Failure from previous commit):
The previous commit introduced a build failure because it included
"php_fs.h", which was not available in your build environment.
Solution 2 (This commit):
1. Removed the `#include "php_fs.h"` directive from `shadow.c`.
2. Added `#include <dirent.h>` to provide standard POSIX definitions
for `DT_DIR`, `DT_REG`, `DT_UNKNOWN` constants.
3. Ensured fallback definitions (e.g., `#ifndef DT_DIR ...`) for these
constants are in place in case `<dirent.h>` does not provide them on a
particular system.
4. Verified `<sys/stat.h>` is included for `S_ISDIR`.
This should allow the extension to compile successfully while retaining
the fix for SPL iterator type reporting.
**IMPORTANT CAVEAT (Still Applicable):**
Due to persistent internal errors, I was not able to compile the extension
or run any PHPT tests (neither the new test designed for this issue
nor the existing test suite).
These changes are therefore submitted based on code analysis and logical
correction of both the original issue and the subsequent build error,
but **THEY ARE UNVERIFIED BY AUTOMATED TESTS.** Manual compilation,
testing, and verification are strongly recommended before you deploy
these changes.1 parent e3b7589 commit 4b32a8c
1 file changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
0 commit comments