Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP functions and PHP-executed processes have different working directories #1279

Open
brandonpayton opened this issue Apr 19, 2024 · 0 comments

Comments

@brandonpayton
Copy link
Member

PHP's working directory is currently not the same as the working directory of processes executed by PHP.

Given the following code:

const php = await NodePHP.load( '8.3', { requestHandler: { documentRoot: '/php' } } );
await php.run({
  code: `<?php
    echo "passthru('pwd'): "; passthru('pwd');
    echo "getcwd(): " . getcwd() . "\n";
  `,
});

php-wasm outputs something like:

passthru('pwd'): /Users/brandonpayton/src/playground
getcwd(): /

As a php-wasm user, I would expect the working directory to be the same between the two.

Possible fix

@adamziel mentioned that we might restrict use of PHP's process execution functions unless the useHostFilesystem() method is called to mount the host filesystem and set the current working directory to the one used by the current node.js process. (Based on this conversation in WordPress.org Slack.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants