Skip to content

Commit 9976df4

Browse files
committed
Set follow to true by default, but allow overriding
1 parent 92d0ce7 commit 9976df4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/php-wasm/node/src/lib/load-runtime.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,24 @@ export async function loadNodeRuntime(
9292
*/
9393
if (options?.followSymlinks === true) {
9494
/**
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.
95+
* By default, Emscripten will not follow symlinks when it's the final path component.
96+
* This behavior can cause issues in PHP-wasm when the caller requires the symlink to be followed,
97+
* but the PHP-wasm call to lookupPath didn't explicitly set follow to true.
9898
*
99-
* To work around this, we override the `lookupPath` function to always follow the symlink.
99+
* To ensure symlinks are followed by default when symlink following is enabled in PHP-wasm,
100+
* we override the `lookupPath` function and set follow to true.
100101
*
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.
102+
* PHP and Emscripten functions can still override the default behavior
103+
* by setting follow to false which is required for function calls like lstat.
104104
*/
105105
const lookupPath = phpRuntime.FS.lookupPath;
106106
phpRuntime.FS.lookupPath = (
107107
path: string,
108108
options: any = {}
109109
) => {
110110
return lookupPath(path, {
111+
follow: true,
111112
...options,
112-
follow: true, // TODO: This should be overridable by options.follow.
113113
});
114114
};
115115

0 commit comments

Comments
 (0)