[PHP-CVS] [php-src] master: fix: flaky cli server when parallel (#23238)

[email protected] (NickSdot via GitHub)
Newsgroups php.cvs
Message-ID <[email protected]>
Author: NickSdot (NickSdot)
Committer: GitHub (web-flow)
Pusher: arnaud-lb
Date: 2026-08-13T18:45:02+02:00

Commit: https://github.com/php/php-src/commit/2b57e3b358423e0db5ce32caf66cddcc9e6d0f84
Raw diff: https://github.com/php/php-src/commit/2b57e3b358423e0db5ce32caf66cddcc9e6d0f84.diff

fix: flaky cli server when parallel (#23238)

Changed paths:
  M  sapi/cli/tests/php_cli_server.inc
  M  sapi/cli/tests/php_cli_server_002.phpt


Diff:

diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc
index 3ad6ced5cb44..feee2bbb5686 100644
--- a/sapi/cli/tests/php_cli_server.inc
+++ b/sapi/cli/tests/php_cli_server.inc
@@ -16,8 +16,8 @@ function php_cli_server_start(
     $php_executable = getenv('TEST_PHP_EXECUTABLE') ?: PHP_BINARY;
     $error = null;
 
-    // Create dedicated doc root to avoid index.php clashes between tests.
-    $doc_root = __DIR__ . DIRECTORY_SEPARATOR . basename($_SERVER['PHP_SELF'], '.php');
+    // Create dedicated doc root to avoid index.php clashes between processes.
+    $doc_root = __DIR__ . DIRECTORY_SEPARATOR . basename($_SERVER['PHP_SELF'], '.php') . '-' . getmypid();
     @mkdir($doc_root);
 
     if ($code) {
diff --git a/sapi/cli/tests/php_cli_server_002.phpt b/sapi/cli/tests/php_cli_server_002.phpt
index d2b561b8bb6b..e3204c06ee8d 100644
--- a/sapi/cli/tests/php_cli_server_002.phpt
+++ b/sapi/cli/tests/php_cli_server_002.phpt
@@ -13,7 +13,7 @@ php_cli_server_start('var_dump($_SERVER["DOCUMENT_ROOT"], $_SERVER["SERVER_SOFTW
 var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS));
 ?>
 --EXPECTF--
-string(%d) "string(%d) "%sphp_cli_server_002"
+string(%d) "string(%d) "%sphp_cli_server_002-%d"
 string(%d) "PHP/%s (Development Server)"
 string(%d) "localhost"
 string(%d) "%s"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.