File tree Expand file tree Collapse file tree 3 files changed +37
-6
lines changed
php-wasm/universal/src/lib Expand file tree Collapse file tree 3 files changed +37
-6
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ export {
79
79
} from './urls' ;
80
80
81
81
export { isExitCode } from './is-exit-code' ;
82
- export { proxyFileSystem } from './proxy-file-system' ;
82
+ export { proxyFileSystem , isPathToSharedFS } from './proxy-file-system' ;
83
83
export { sandboxedSpawnHandlerFactory } from './sandboxed-spawn-handler-factory' ;
84
84
85
85
export * from './api' ;
Original file line number Diff line number Diff line change @@ -34,3 +34,23 @@ export function proxyFileSystem(
34
34
) ;
35
35
}
36
36
}
37
+
38
+ /**
39
+ * Answers whether the given path is to a shared filesystem.
40
+ *
41
+ * @param sourceOfTruth - The PHP instance that is the source of truth.
42
+ * @param path - The path to check.
43
+ * @returns True if the path is to a shared filesystem, false otherwise.
44
+ */
45
+ export function isPathToSharedFS ( sourceOfTruth : PHP , path : string ) {
46
+ // We can't just import the symbol from the library because
47
+ // Playground CLI is built as ESM and php-wasm-node is built as
48
+ // CJS and the imported symbols will different in the production build.
49
+ const __private__symbol = Object . getOwnPropertySymbols ( sourceOfTruth ) [ 0 ] ;
50
+
51
+ // @ts -ignore
52
+ const FS = sourceOfTruth [ __private__symbol ] . FS ;
53
+
54
+ const fsResult = FS . lookupPath ( path , { noent_okay : true } ) ;
55
+ return fsResult ?. node ?. isSharedFS ?? false ;
56
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
10
10
PHP ,
11
11
PHPRequestHandler ,
12
12
proxyFileSystem ,
13
+ isPathToSharedFS ,
13
14
rotatePHPRuntime ,
14
15
sandboxedSpawnHandlerFactory ,
15
16
setPhpIniEntries ,
@@ -267,13 +268,23 @@ export async function bootRequestHandler(options: BootRequestHandlerOptions) {
267
268
joinPaths ( new URL ( options . siteUrl ) . pathname , 'phpinfo.php' )
268
269
) ;
269
270
} else {
270
- // Proxy the filesystem for all secondary PHP instances to
271
- // the primary one.
272
- proxyFileSystem ( await requestHandler . getPrimaryPhp ( ) , php , [
271
+ const pathsToShareBetweenPhpInstances = [
273
272
'/tmp' ,
274
273
requestHandler . documentRoot ,
275
- '/internal' ,
276
- ] ) ;
274
+ '/internal/shared' ,
275
+ '/internal/symlinks' ,
276
+ ] ;
277
+ const pathsToProxy = pathsToShareBetweenPhpInstances . filter (
278
+ ( path ) => ! isPathToSharedFS ( php , path )
279
+ ) ;
280
+
281
+ // Proxy the filesystem for all secondary PHP instances to
282
+ // the primary one.
283
+ proxyFileSystem (
284
+ await requestHandler . getPrimaryPhp ( ) ,
285
+ php ,
286
+ pathsToProxy
287
+ ) ;
277
288
}
278
289
279
290
// Spawn handler is responsible for spawning processes for all the
You can’t perform that action at this time.
0 commit comments