Skip to content

Commit 2e3d13e

Browse files
committed
Merge branch 'PHP-8.2'
2 parents 02a5335 + e7b6c2e commit 2e3d13e

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

sapi/fpm/fpm/fpm_main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,9 @@ consult the installation file that came with this distribution, or visit \n\
18961896

18971897
fpm_request_executing();
18981898

1899+
/* Reset exit status from the previous execution */
1900+
EG(exit_status) = 0;
1901+
18991902
php_execute_script(&file_handle);
19001903

19011904
fastcgi_request_done:
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--TEST--
2+
FPM: gh9981 - fastcgi.error_header is not reset
3+
--SKIPIF--
4+
<?php
5+
include "skipif.inc"; ?>
6+
--FILE--
7+
<?php
8+
9+
require_once "tester.inc";
10+
11+
$cfg = <<<EOT
12+
[global]
13+
error_log = {{FILE:LOG}}
14+
[unconfined]
15+
listen = {{ADDR}}
16+
pm = static
17+
pm.max_children = 1
18+
catch_workers_output = yes
19+
EOT;
20+
21+
$code = <<<EOT
22+
<?php
23+
if (isset(\$_GET['q'])) {
24+
echo 'ok';
25+
} else {
26+
d();
27+
}
28+
EOT;
29+
30+
$tester = new FPM\Tester($cfg, $code);
31+
$tester->start(iniEntries: [
32+
'fastcgi.error_header' => '"HTTP/1.1 500 PHP Error"',
33+
'output_buffering' => 4096,
34+
]);
35+
$tester->expectLogStartNotices();
36+
$tester->request()->expectStatus('500 PHP Error');
37+
$tester->request('q=1')->expectNoStatus();
38+
$tester->terminate();
39+
$tester->expectLogTerminatingNotices();
40+
$tester->expectNoLogPattern('/Cannot modify header information/');
41+
$tester->close();
42+
43+
?>
44+
Done
45+
--EXPECT--
46+
Done
47+
--CLEAN--
48+
<?php
49+
require_once "tester.inc";
50+
FPM\Tester::clean();
51+
?>

sapi/fpm/tests/response.inc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,37 @@ class Response
170170
return $this;
171171
}
172172

173+
/**
174+
* Expect response status.
175+
*
176+
* @param string|null $status Expected status.
177+
*
178+
* @return Response
179+
*/
180+
public function expectStatus(string|null $status): Response {
181+
$headers = $this->getHeaders();
182+
if (is_null($status) && !isset($headers['status'])) {
183+
return $this;
184+
}
185+
if (!is_null($status) && !isset($headers['status'])) {
186+
$this->error('Status is expected but not supplied');
187+
} elseif ($status !== $headers['status']) {
188+
$statusMessage = $status === null ? "expected not to be set": "expected to be $status";
189+
$this->error("Status is $statusMessage but the actual value is {$headers['status']}");
190+
}
191+
192+
return $this;
193+
}
194+
195+
/**
196+
* Expect response status not to be set.
197+
*
198+
* @return Response
199+
*/
200+
public function expectNoStatus(): Response {
201+
return $this->expectStatus(null);
202+
}
203+
173204
/**
174205
* Expect no error in the response.
175206
*

0 commit comments

Comments
 (0)