[php-src] Issue #13743: proc_open inaccessible cwd behavior change in 8.3
| From: | divinity76 | Date: | Mon, 18 Mar 2024 08:43:48 +0000 |
| Subject: | [php-src] Issue #13743: proc_open inaccessible cwd behavior change in 8.3 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246603@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13743
Author: divinity76
### Description
As of PHP8.3, the following code:
```php
<?php
$descriptorspec = array();
$cwd = '/inaccessible/dir/';
$process = proc_open('/usr/bin/env php -r ""', $descriptorspec, $pipes, $cwd);
proc_close($process);
```
Resulted in this output:
```
PHP Warning: proc_open(): posix_spawn() failed: No such file or directory in
/home/hans/test/test.php on line 4
PHP Fatal error: Uncaught TypeError: proc_close(): Argument #1 ($process) must be of type resource,
false given in /home/hans/test/test.php:5
Stack trace:
#0 /home/hans/test/test.php(5): proc_close()
#1 {main}
thrown in /home/hans/test/test.php on line 5
```
But in PHP<8.3, it results in no output whatsoever, and proc_open succeeds.
This behavior change breaks real code in the wild: https://github.com/chrome-php/wrench/pull/20
While I think the behavior change is good, I also think a E_DEPRECATED period is warranted,
something like
>Requesting an inaccessible working dir ($cwd) has been deprecated and will stop working in a
>future version of PHP
### PHP Version
PHP8.3.0
### Operating System
Ubuntu (both 22.04 and 24.04-beta)