Commit c9433e1ff13 for php
commit c9433e1ff13fc29850fc949923a457ea906cdc81
Author: aasul <aasim.slmns@eduge.ch>
Date: Tue Oct 27 10:40:10 2026 +0100
Add FPM test for INI diagnostics after fatal error with backtrace (#24638)
Co-authored-by: aasim <aasulaiman@gmail.com>
diff --git a/sapi/fpm/tests/fatal-error-backtrace-request-reset.phpt b/sapi/fpm/tests/fatal-error-backtrace-request-reset.phpt
new file mode 100644
index 00000000000..da6941e5b39
--- /dev/null
+++ b/sapi/fpm/tests/fatal-error-backtrace-request-reset.phpt
@@ -0,0 +1,66 @@
+--TEST--
+FPM: fatal error backtrace is reset before the next request's INI diagnostics
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+
+require_once "tester.inc";
+
+$cfg = <<<EOT
+[global]
+error_log = {{FILE:LOG}}
+[unconfined]
+listen = {{ADDR}}
+pm = static
+pm.max_children = 1
+env[ZEND_ASAN_FORCE_FAST_SHUTDOWN] = 1
+EOT;
+
+$code = <<<'PHP'
+<?php
+echo getmypid(), "\n";
+if (isset($_GET['fatal'])) {
+ function trigger_fatal() {
+ eval("class RequestReset {}; class RequestReset {}");
+ }
+ trigger_fatal();
+}
+echo date_default_timezone_get(), "\n";
+PHP;
+
+$tester = new FPM\Tester($cfg, $code);
+$tester->start(iniEntries: [
+ 'fatal_error_backtraces' => '1',
+ 'display_errors' => '0',
+ 'log_errors' => '1',
+ 'date.timezone' => 'UTC',
+]);
+$tester->expectLogStartNotices();
+$response = $tester->request('fatal=1')->expectErrorPattern(
+ '/\APHP message: PHP Fatal error: Cannot redeclare class RequestReset\b[^\n]*\n'
+ . 'Stack trace:\n#0 [^\n]*: eval\(\)\n'
+ . '#1 [^\n]*: trigger_fatal\(\)\n#2 \{main\}\z/'
+);
+$pid = $response->getBody();
+var_dump(preg_match('/^\d+$/D', $pid) === 1);
+
+/* PHP_VALUE is applied before php_request_startup(), while shutdown is still flagged. */
+$tester->request(headers: ['PHP_VALUE' => 'date.timezone=invalid'])
+ ->expectBody($pid . "\nUTC")
+ ->expectError("PHP message: PHP Warning: PHP Request Shutdown: "
+ . "Invalid date.timezone value 'invalid', using 'UTC' instead in Unknown on line 0");
+$tester->terminate();
+$tester->expectLogTerminatingNotices();
+$tester->close();
+
+?>
+Done
+--EXPECT--
+bool(true)
+Done
+--CLEAN--
+<?php
+require_once "tester.inc";
+FPM\Tester::clean();
+?>