File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed
packages/php-wasm/universal/src/lib Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -206,9 +206,7 @@ export class PHPRequestHandler implements AsyncDisposable {
206206 getFileNotFoundAction = ( ) => ( { type : '404' } ) ,
207207 } = config ;
208208
209- if ( 'php' in config ) {
210- const php = config . php ;
211-
209+ const setChroot = ( php : PHP ) => {
212210 // Always set managed PHP's cwd to the document root.
213211 if ( ! php . isDir ( documentRoot ) ) {
214212 php . mkdir ( documentRoot ) ;
@@ -217,24 +215,21 @@ export class PHPRequestHandler implements AsyncDisposable {
217215
218216 // @TODO : Decouple PHP and request handler
219217 ( php as any ) . requestHandler = this ;
218+ } ;
220219
221- this . processManager = new SinglePHPInstanceManager ( { php } ) ;
220+ if ( 'php' in config ) {
221+ setChroot ( config . php ) ;
222+ this . processManager = new SinglePHPInstanceManager ( {
223+ php : config . php ,
224+ } ) ;
222225 } else {
223226 this . processManager = new PHPProcessManager ( {
224227 phpFactory : async ( info ) => {
225228 const php = await config . phpFactory ( {
226229 ...info ,
227230 requestHandler : this ,
228231 } ) ;
229-
230- // Always set managed PHP's cwd to the document root.
231- if ( ! php . isDir ( documentRoot ) ) {
232- php . mkdir ( documentRoot ) ;
233- }
234- php . chdir ( documentRoot ) ;
235-
236- // @TODO : Decouple PHP and request handler
237- ( php as any ) . requestHandler = this ;
232+ setChroot ( php ) ;
238233 return php ;
239234 } ,
240235 maxPhpInstances : config . maxPhpInstances ,
You can’t perform that action at this time.
0 commit comments