-
Notifications
You must be signed in to change notification settings - Fork 264
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
Cannot set PHP temporary directory in CLI (sys_temp_dir) #828
Labels
Comments
adamziel
added
[Type] Bug
An existing feature does not function as intended
[Package][@php-wasm] CLI
labels
Dec 1, 2023
Closed
adamziel
changed the title
Invalid sys_temp_dir in php-wasm-cli
Cannot set PHP temporary directory in CLI (sys_temp_dir)
Dec 1, 2023
Setting the
|
adamziel
added a commit
that referenced
this issue
Jan 17, 2024
## The problem * `npm` scripts set the TMPDIR env variable * PHP accepts a TMPDIR env variable and expects it to be a writable directory within the PHP filesystem. These two clash and prevent PHP from creating temporary files and directories so this PR prevents exposing the npm-set `TMPDIR` env variable to PHP. Closes #828 ## Testing instructions Run the following PHP script with and without this PR: ```php <?php var_dump(sys_get_temp_dir()); var_dump(tmpfile()); ``` Run it as follows: ``` nx reset; PHP=8.2 nx start php-wasm-cli ``` Without this PR, it should print something like this: ``` string(48) "/var/folders/sb/cywb762129g3f0jzq1_p2q5h0000gp/T" bool(false) ``` With this PR, it should print this: ``` string(4) "/tmp" resource(4) of type (stream) ```
adamziel
added a commit
that referenced
this issue
Jan 17, 2024
* `npm` scripts set the TMPDIR env variable * PHP accepts a TMPDIR env variable and expects it to be a writable directory within the PHP filesystem. These two clash and prevent PHP from creating temporary files and directories so this PR prevents exposing the npm-set `TMPDIR` env variable to PHP. Closes #828 ## Testing instructions Run the following PHP script with and without this PR: ```php <?php var_dump(sys_get_temp_dir()); var_dump(tmpfile()); ``` Run it as follows: ``` nx reset; PHP=8.2 nx start php-wasm-cli ``` Without this PR, it should print something like this: ``` string(48) "/var/folders/sb/cywb762129g3f0jzq1_p2q5h0000gp/T" bool(false) ``` With this PR, it should print this: ``` string(4) "/tmp" resource(4) of type (stream) ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
php-wasm-cli cannot create temporary files because it doesn't seem to use any custom
sys_temp_dir
value.This program:
Gives this output:
When ran as:
I tried feeding
sys_temp_dir
throughphp.ini
andphp.setPhpIniEntry
without any luck.Done is
Programs ran via
php-wasm-cli
can create temporary files and directories in the temporary dir defined bysys_temp_dir
The text was updated successfully, but these errors were encountered: