Commit b9f41139cff for php

commit b9f41139cff9c98c5f1375aab8b6ff59b6d93b22
Author: Michael Orlitzky <michael@orlitzky.com>
Date:   Mon Jul 10 21:42:19 2023 -0400

    {ext/standard,sapi/cli}/tests: pass TEST_PHP_EXTRA_ARGS to php

    Several of these tests fail to pass TEST_PHP_EXTRA_ARGS to
    the PHP binary they execute. This can lead to spurious failures when,
    for example, the system's INI file is incompatible with the just-built
    CLI php:

      ---- EXPECTED OUTPUT
      int(111)
      ---- ACTUAL OUTPUT
      Failed loading /usr/lib64/php8.2/lib64/opcache.so:
      /usr/lib64/php8.2/lib64/opcache.so: undefined symbol: _emalloc_32
      int(111)
      ---- FAILED

    This commit adds TEST_PHP_EXTRA_ARGS to the "php" invocations that are
    missing them, allowing the user to run "run-tests.php -n" to work
    around the problem.

diff --git a/ext/standard/tests/file/bug60120.phpt b/ext/standard/tests/file/bug60120.phpt
index 65027982cf9..59d9606a94e 100644
--- a/ext/standard/tests/file/bug60120.phpt
+++ b/ext/standard/tests/file/bug60120.phpt
@@ -14,7 +14,9 @@
 error_reporting(E_ALL);

 $php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
-$cmd = $php . ' -r "\$in = file_get_contents(\'php://stdin\'); fwrite(STDOUT, \$in); fwrite(STDERR, \$in);"';
+$args = getenv('TEST_PHP_EXTRA_ARGS');
+$cmd = ' -r "\$in = file_get_contents(\'php://stdin\'); fwrite(STDOUT, \$in); fwrite(STDERR, \$in);"';
+$cmd = join(' ', [$php, $args, $cmd]);
 $descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
 $stdin = str_repeat('*', 2049 );

diff --git a/ext/standard/tests/ini_info/php_ini_loaded_file.phpt b/ext/standard/tests/ini_info/php_ini_loaded_file.phpt
index 1fce24e67fe..4e3085ba865 100644
--- a/ext/standard/tests/ini_info/php_ini_loaded_file.phpt
+++ b/ext/standard/tests/ini_info/php_ini_loaded_file.phpt
@@ -2,15 +2,16 @@
 php_ini_loaded_file() function
 --FILE--
 <?php
-    $inifile = __DIR__.DIRECTORY_SEPARATOR.'loaded.ini';
+    $inifile = escapeshellarg(__DIR__.DIRECTORY_SEPARATOR.'loaded.ini');
     $php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
+    $args = getenv('TEST_PHP_EXTRA_ARGS');
     $code = '"var_dump(php_ini_loaded_file());"';

     // No ini file
-    passthru($php.' -n -r '.$code);
+    passthru("$php $args -n -r $code");

     // Specified ini file
-    passthru($php.' -c '.escapeshellarg($inifile).' -r '.$code);
+    passthru("$php $args -c $inifile -r $code");
 ?>
 --EXPECTREGEX--
 bool\(false\)
diff --git a/sapi/cli/tests/016.phpt b/sapi/cli/tests/016.phpt
index 544633f592f..3c0aa56e44a 100644
--- a/sapi/cli/tests/016.phpt
+++ b/sapi/cli/tests/016.phpt
@@ -12,6 +12,7 @@
 --FILE--
 <?php
 $php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
+$args = getenv('TEST_PHP_EXTRA_ARGS');

 // disallow console escape sequences that may break the output
 putenv('TERM=VT100');
@@ -56,7 +57,7 @@ function a_function_with_some_name() {
 foreach ($codes as $key => $code) {
     echo "\n--------------\nSnippet no. $key:\n--------------\n";
     $code = escapeshellarg($code);
-    echo `echo $code | $php -a`, "\n";
+    echo `echo $code | $php $args -a`, "\n";
 }

 echo "\nDone\n";
diff --git a/sapi/cli/tests/bug65275.phpt b/sapi/cli/tests/bug65275.phpt
index 9ccb165466e..e9a326595c3 100644
--- a/sapi/cli/tests/bug65275.phpt
+++ b/sapi/cli/tests/bug65275.phpt
@@ -4,7 +4,8 @@
 <?php

 $php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
-exec($php . ' ' . escapeshellarg(__DIR__ . '/bug65275.inc'), $output, $exit_status);
+$args = getenv('TEST_PHP_EXTRA_ARGS');
+exec($php . ' ' . $args . ' ' . escapeshellarg(__DIR__ . '/bug65275.inc'), $output, $exit_status);
 var_dump($exit_status);

 ?>
diff --git a/sapi/cli/tests/bug74600.phpt b/sapi/cli/tests/bug74600.phpt
index 01da61a0660..e52056d40a3 100644
--- a/sapi/cli/tests/bug74600.phpt
+++ b/sapi/cli/tests/bug74600.phpt
@@ -8,6 +8,7 @@
 --FILE--
 <?php
 $php = getenv("TEST_PHP_EXECUTABLE_ESCAPED");
+$args = getenv("TEST_PHP_EXTRA_ARGS");
 $ini_file = __DIR__ . "/bug74600.ini";
 $ini_file_escaped = escapeshellarg($ini_file);
 file_put_contents($ini_file, <<<INI
@@ -20,7 +21,7 @@
     2 => array("pipe", "w"),
 );
 $pipes = array();
-$proc = proc_open("$php -c $ini_file_escaped -r 'echo \"okey\";'", $desc, $pipes);
+$proc = proc_open("$php $args -c $ini_file_escaped -r 'echo \"okey\";'", $desc, $pipes);
 if (!$proc) {
     exit(1);
 }
diff --git a/sapi/cli/tests/bug78323.phpt b/sapi/cli/tests/bug78323.phpt
index d353281a0e8..c9799db9e55 100644
--- a/sapi/cli/tests/bug78323.phpt
+++ b/sapi/cli/tests/bug78323.phpt
@@ -7,6 +7,7 @@
 --FILE--
 <?php
 $php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
+$args = getenv('TEST_PHP_EXTRA_ARGS');

 // There are 3 types of option errors:
 // 1 : in flags
@@ -16,7 +17,7 @@

 // colon in flags
 ob_start();
-passthru("$php -a:Z 2>&1", $exitCode);
+passthru("$php $args -a:Z 2>&1", $exitCode);
 $output = ob_get_contents();
 ob_end_clean();

@@ -28,7 +29,7 @@

 // option not found
 ob_start();
-passthru("$php -Z 2>&1", $exitCode);
+passthru("$php $args -Z 2>&1", $exitCode);
 $output = ob_get_contents();
 ob_end_clean();

@@ -40,7 +41,7 @@

 // no argument for option
 ob_start();
-passthru("$php --memory-limit=1G 2>&1", $exitCode);
+passthru("$php $args --memory-limit=1G 2>&1", $exitCode);
 $output = ob_get_contents();
 ob_end_clean();

@@ -52,7 +53,7 @@

 // Successful execution
 ob_start();
-passthru("$php -dmemory-limit=1G -v", $exitCode);
+passthru("$php $args -dmemory-limit=1G -v", $exitCode);
 $output = ob_get_contents();
 ob_end_clean();