File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
packages/php-wasm/node/src/lib Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,28 @@ export async function loadNodeRuntime(
91
91
* for the path and Emscripten will accept it as if it was the real link path.
92
92
*/
93
93
if ( options ?. followSymlinks === true ) {
94
+ /**
95
+ * PHP might call `lookupPath` with `follow: false`.
96
+ * When this happens Emscripten will not follow the symlink when it's the final path component.
97
+ * This happens for example during a is_dir check or lstat.
98
+ *
99
+ * To work around this, we override the `lookupPath` function to always follow the symlink.
100
+ *
101
+ * TODO:
102
+ * - Understand why we must override follow: false when it's explicitly required by the caller.
103
+ * - Find a way to set follow: true as the default behavior, but allow the caller to override it.
104
+ */
105
+ const lookupPath = phpRuntime . FS . lookupPath ;
106
+ phpRuntime . FS . lookupPath = (
107
+ path : string ,
108
+ options : any = { }
109
+ ) => {
110
+ return lookupPath ( path , {
111
+ ...options ,
112
+ follow : true , // TODO: This should be overridable by options.follow.
113
+ } ) ;
114
+ } ;
115
+
94
116
phpRuntime . FS . filesystems . NODEFS . node_ops . readlink = (
95
117
node : any
96
118
) => {
You can’t perform that action at this time.
0 commit comments