[php-src] PHP-8.5: ext/standard/tests: work around Windows quoting with tempfiles.

From: Date: Wed, 14 Oct 2026 17:44:25 +0000
Subject: [php-src] PHP-8.5: ext/standard/tests: work around Windows quoting with tempfiles.
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142283@lists.php.net to get a copy of this message
Author: Michael Orlitzky (orlitzky) Committer: Gina Peter Banyard (Girgias) Date: 2026-10-14T18:34:22+01:00 Commit: https://github.com/php/php-src/commit/077d7d6024f7bb7b1183fdae51745880abac76a6 Raw diff: https://github.com/php/php-src/commit/077d7d6024f7bb7b1183fdae51745880abac76a6.diff ext/standard/tests: work around Windows quoting with tempfiles. Two of our proc_open() tests pass code to PHP via the shell, leading to three levels of quoting, one of which makes cmd.exe unhappy on Windows. To avoid the issue, we use a temporary file instead, and pass only the (at most, once-quoted) name of the file to PHP. Closes GH-11669 Changed paths: M ext/standard/tests/general_functions/proc_open_null.phpt M ext/standard/tests/general_functions/proc_open_redirect.phpt Diff: diff --git a/ext/standard/tests/general_functions/proc_open_null.phpt b/ext/standard/tests/general_functions/proc_open_null.phpt index f5ea603f04b8..6c869725dd23 100644 --- a/ext/standard/tests/general_functions/proc_open_null.phpt +++ b/ext/standard/tests/general_functions/proc_open_null.phpt @@ -5,7 +5,9 @@ Null pipes in proc_open() $php = getenv('TEST_PHP_EXECUTABLE'); $args = getenv('TEST_PHP_EXTRA_ARGS'); -$cmd = "$php $args -r 'echo \"Test\"; fprintf(STDERR, \"Error\");'"; +$fn = tempnam(sys_get_temp_dir(), "PROC_OPEN_TEST"); +$cmd = "$php $args " . escapeshellarg($fn); +file_put_contents($fn, '<?php echo "Test"; fprintf(STDERR, "Error");'); $proc = proc_open($cmd, [1 => ['null'], 2 => ['pipe', 'w']], $pipes); var_dump($pipes); @@ -16,16 +18,17 @@ $proc = proc_open($cmd, [1 => ['pipe', 'w'], 2 => ['null']], $pipes); var_dump($pipes); var_dump(stream_get_contents($pipes[1])); proc_close($proc); +unlink($fn); ?> --EXPECT-- array(1) { [2]=> - resource(4) of type (stream) + resource(6) of type (stream) } string(5) "Error" array(1) { [1]=> - resource(6) of type (stream) + resource(8) of type (stream) } string(4) "Test" diff --git a/ext/standard/tests/general_functions/proc_open_redirect.phpt b/ext/standard/tests/general_functions/proc_open_redirect.phpt index c8d29e894776..add5e6031ee5 100644 --- a/ext/standard/tests/general_functions/proc_open_redirect.phpt +++ b/ext/standard/tests/general_functions/proc_open_redirect.phpt @@ -26,7 +26,9 @@ try { } echo "\nWith pipe:\n"; -$cmd = "$php $args -r 'echo \"Test\n\"; fprintf(STDERR, \"Error\");'"; +$fn = tempnam(sys_get_temp_dir(), "PROC_OPEN_TEST"); +file_put_contents($fn, '<?php echo "Test\n"; fprintf(STDERR, "Error");'); +$cmd = "$php $args " . escapeshellarg($fn); $proc = proc_open($cmd, [1 => ['pipe', 'w'], 2 => ['redirect', 1]], $pipes); var_dump($pipes); var_dump(stream_get_contents($pipes[1])); @@ -52,6 +54,7 @@ unlink($fileName); echo "\nWith inherited stdout:\n"; $proc = proc_open($cmd, [2 => ['redirect', 1]], $pipes); proc_close($proc); +unlink($fn); ?> --EXPECTF-- @@ -63,7 +66,7 @@ Warning: proc_open(): Redirection target 42 not found in %s With pipe: array(1) { [1]=> - resource(4) of type (stream) + resource(6) of type (stream) } string(10) "Test Error"

« previous php.cvs (#142283) next »