Skip to content

Commit e7b6c2e

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
2 parents 9529b89 + a3891d9 commit e7b6c2e

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ PHP NEWS
44

55
- FPM:
66
. Fixed bug #77106 (Missing separator in FPM FastCGI errors). (Jakub Zelenka)
7+
. Fixed bug GH-9981 (FPM does not reset fastcgi.error_header).
8+
(Jakub Zelenka)
79

810
- LDAP:
911
. Fixed bug GH-10112 (LDAP\Connection::__construct() refers to ldap_create()).

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
@@ -159,6 +159,37 @@ class Response
159159
return $this;
160160
}
161161

162+
/**
163+
* Expect response status.
164+
*
165+
* @param string|null $status Expected status.
166+
*
167+
* @return Response
168+
*/
169+
public function expectStatus(string|null $status): Response {
170+
$headers = $this->getHeaders();
171+
if (is_null($status) && !isset($headers['status'])) {
172+
return $this;
173+
}
174+
if (!is_null($status) && !isset($headers['status'])) {
175+
$this->error('Status is expected but not supplied');
176+
} elseif ($status !== $headers['status']) {
177+
$statusMessage = $status === null ? "expected not to be set": "expected to be $status";
178+
$this->error("Status is $statusMessage but the actual value is {$headers['status']}");
179+
}
180+
181+
return $this;
182+
}
183+
184+
/**
185+
* Expect response status not to be set.
186+
*
187+
* @return Response
188+
*/
189+
public function expectNoStatus(): Response {
190+
return $this->expectStatus(null);
191+
}
192+
162193
/**
163194
* Expect no error in the response.
164195
*

0 commit comments

Comments
 (0)