Skip to content

Commit f953bd9

Browse files
committed
Merge branch 'PHP-8.4'
2 parents f12b231 + e699753 commit f953bd9

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed

sapi/fpm/fpm/fpm_request.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void fpm_request_end(void)
201201
fpm_scoreboard_proc_release(proc);
202202

203203
/* memory_peak */
204-
fpm_scoreboard_update_commit(0, 0, 0, 0, 0, 0, 0, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);
204+
fpm_scoreboard_update_commit(-1, -1, -1, -1, -1, -1, -1, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);
205205
}
206206

207207
void fpm_request_finished(void)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
--TEST--
2+
FPM: GH-16932 - scoreboard fields are reset after the request
3+
--EXTENSIONS--
4+
pcntl
5+
--SKIPIF--
6+
<?php
7+
include "skipif.inc";
8+
?>
9+
--FILE--
10+
<?php
11+
12+
require_once "tester.inc";
13+
14+
$cfg = <<<EOT
15+
[global]
16+
error_log = {{FILE:LOG}}
17+
pid = {{FILE:PID}}
18+
[unconfined]
19+
listen = {{ADDR}}
20+
pm.status_path = /status
21+
pm = dynamic
22+
pm.max_children = 2
23+
pm.start_servers = 1
24+
pm.min_spare_servers = 1
25+
pm.max_spare_servers = 1
26+
EOT;
27+
28+
$code = <<<EOT
29+
<?php
30+
echo "hi!";
31+
EOT;
32+
33+
34+
$tester = new FPM\Tester($cfg, $code);
35+
$tester->start(extensions: ['pcntl']);
36+
$tester->expectLogStartNotices();
37+
$tester->request();
38+
$tester->request();
39+
$tester->request();
40+
$tester->request();
41+
$tester
42+
->request(uri: '/status', query: 'json')
43+
->expectJsonBodyPatternForStatusField('accepted conn', '5');
44+
$tester->terminate();
45+
$tester->expectLogTerminatingNotices();
46+
$tester->close();
47+
48+
?>
49+
Done
50+
--EXPECT--
51+
Done
52+
--CLEAN--
53+
<?php
54+
require_once "tester.inc";
55+
FPM\Tester::clean();
56+
?>

sapi/fpm/tests/response.inc

+24-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,29 @@ class Response extends BaseResponse
148148
return $this;
149149
}
150150

151+
/**
152+
* Expect status field with value that matches the supplied pattern.
153+
*
154+
* @param string $fieldName
155+
* @param string $pattern
156+
*
157+
* @return Response
158+
*/
159+
public function expectJsonBodyPatternForStatusField(string $fieldName, string $pattern): Response
160+
{
161+
$rawData = $this->getBody('application/json');
162+
$data = json_decode($rawData, true);
163+
if (preg_match('|' . $pattern . '|', $data[$fieldName]) > 0) {
164+
return $this;
165+
}
166+
167+
$this->error(
168+
"Field $fieldName did not match pattern $pattern in status data '$rawData'"
169+
);
170+
171+
return $this;
172+
}
173+
151174
/**
152175
* Expect that one of the processes in json status process list has a field with value that
153176
* matches the supplied pattern.
@@ -167,7 +190,7 @@ class Response extends BaseResponse
167190
);
168191
}
169192
foreach ($data['processes'] as $process) {
170-
if (preg_match('|' . $pattern . '|', $process[$fieldName]) !== false) {
193+
if (preg_match('|' . $pattern . '|', $process[$fieldName]) > 0) {
171194
return $this;
172195
}
173196
}

0 commit comments

Comments
 (0)