Commit 077d7d6024f for php

commit 077d7d6024f7bb7b1183fdae51745880abac76a6
Author: Michael Orlitzky <michael@orlitzky.com>
Date:   Fri Jul 14 21:49:39 2023 -0400

    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

diff --git a/ext/standard/tests/general_functions/proc_open_null.phpt b/ext/standard/tests/general_functions/proc_open_null.phpt
index f5ea603f04b..6c869725dd2 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 @@

 $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 @@
 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 c8d29e89477..add5e6031ee 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 @@
 }

 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 @@
 echo "\nWith inherited stdout:\n";
 $proc = proc_open($cmd, [2 => ['redirect', 1]], $pipes);
 proc_close($proc);
+unlink($fn);

 ?>
 --EXPECTF--
@@ -63,7 +66,7 @@
 With pipe:
 array(1) {
   [1]=>
-  resource(4) of type (stream)
+  resource(6) of type (stream)
 }
 string(10) "Test
 Error"