Skip to content

Commit ca61ef2

Browse files
committed
Only mount native /internal dir in primary PHP process
Secondary PHP processes will proxy /internal to the primary PHP process.
1 parent 89a469b commit ca61ef2

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

packages/playground/cli/src/blueprints-v1/worker-thread-v1.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class PlaygroundCliBlueprintV1Worker extends PHPWorker {
151151

152152
const requestHandler = await bootWordPress({
153153
siteUrl,
154-
createPhpRuntime: async () => {
154+
createPhpRuntime: async (isPrimary) => {
155155
const processId = nextProcessId;
156156

157157
if (nextProcessId < lastProcessId) {
@@ -166,9 +166,13 @@ export class PlaygroundCliBlueprintV1Worker extends PHPWorker {
166166
fileLockManager: this.fileLockManager!,
167167
processId,
168168
trace: trace ? tracePhpWasm : undefined,
169-
phpWasmInitOptions: {
170-
nativeInternalDirPath,
171-
},
169+
phpWasmInitOptions: isPrimary
170+
? // Only pass a native /internal dir to the primary PHP process
171+
// because the secondary PHP process will proxy to it.
172+
{
173+
nativeInternalDirPath,
174+
}
175+
: {},
172176
},
173177
followSymlinks,
174178
withXdebug,

packages/playground/cli/src/blueprints-v2/worker-thread-v2.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export class PlaygroundCliBlueprintV2Worker extends PHPWorker {
386386
try {
387387
const requestHandler = await bootRequestHandler({
388388
siteUrl,
389-
createPhpRuntime: async () => {
389+
createPhpRuntime: async (isPrimary) => {
390390
const processId = nextProcessId;
391391

392392
if (nextProcessId < lastProcessId) {
@@ -404,9 +404,13 @@ export class PlaygroundCliBlueprintV2Worker extends PHPWorker {
404404
ENV: {
405405
DOCROOT: '/wordpress',
406406
},
407-
phpWasmInitOptions: {
408-
nativeInternalDirPath,
409-
},
407+
phpWasmInitOptions: isPrimary
408+
? // Only pass a native /internal dir to the primary PHP process
409+
// because the secondary PHP process will proxy to it.
410+
{
411+
nativeInternalDirPath,
412+
}
413+
: {},
410414
},
411415
followSymlinks: allow?.includes('follow-symlinks'),
412416
withXdebug,

packages/playground/wordpress/src/boot.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface Hooks {
3737
export type DatabaseType = 'sqlite' | 'mysql' | 'custom';
3838

3939
export interface BootRequestHandlerOptions {
40-
createPhpRuntime: () => Promise<number>;
40+
createPhpRuntime: (isPrimary?: boolean) => Promise<number>;
4141
onPHPInstanceCreated?: (php: PHP) => Promise<void>;
4242
/**
4343
* PHP SAPI name to be returned by get_sapi_name(). Overriding
@@ -199,7 +199,8 @@ export async function bootRequestHandler(options: BootRequestHandlerOptions) {
199199
requestHandler: PHPRequestHandler,
200200
isPrimary: boolean
201201
) {
202-
const php = new PHP(await options.createPhpRuntime());
202+
const runtimeId = await options.createPhpRuntime(isPrimary);
203+
const php = new PHP(runtimeId);
203204
if (options.sapiName) {
204205
php.setSapiName(options.sapiName);
205206
}

0 commit comments

Comments
 (0)