1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix GH-19989: PHP 8.5 FPM access log lines also go to STDERR

This was due to not omitting logging using external_log

Closes GH-20123
This commit is contained in:
Jakub Zelenka
2025-10-10 16:21:45 +02:00
parent 01e34156a8
commit 234577ee90
4 changed files with 53 additions and 1 deletions

2
NEWS
View File

@@ -9,6 +9,8 @@ PHP NEWS
- FPM:
. Fixed bug GH-19817 (Decode SCRIPT_FILENAME issue in php 8.5).
(Jakub Zelenka)
. Fixed bug GH-19989 (PHP 8.5 FPM access log lines also go to STDERR).
(Jakub Zelenka)
- Opcache:
. Fixed bug GH-20081 (access to uninitialized vars in preload_load()).

View File

@@ -466,7 +466,7 @@ static ssize_t zlog_stream_buf_flush(struct zlog_stream *stream) /* {{{ */
}
#endif
if (external_logger != NULL) {
if (stream->use_external_logger) {
external_logger(stream->flags & ZLOG_LEVEL_MASK,
stream->buf.data + stream->prefix_len, stream->len - stream->prefix_len);
}
@@ -539,9 +539,11 @@ static inline void zlog_stream_init_internal(
stream->fd = fd > -1 ? fd : STDERR_FILENO;
stream->buf_init_size = capacity;
if (flags & ZLOG_ACCESS_LOG) {
stream->use_external_logger = 0;
stream->use_buffer = 1;
stream->use_stderr = fd < 0;
} else {
stream->use_external_logger = external_logger != NULL;
stream->use_buffer = zlog_buffering || external_logger != NULL || stream->use_syslog;
stream->use_stderr = fd < 0 ||
(

View File

@@ -77,6 +77,7 @@ struct zlog_stream {
unsigned int decorate:1;
unsigned int is_stdout:1;
unsigned int over_limit:1;
unsigned int use_external_logger:1;
int fd;
int line;
int child_pid;

View File

@@ -0,0 +1,47 @@
--TEST--
FPM: GH-19989 - Access log going to fcgi error stream
--SKIPIF--
<?php include "skipif.inc"; ?>
--FILE--
<?php
require_once "tester.inc";
$src = <<<EOT
<?php
echo "OK";
EOT;
$cfg = <<<EOT
[global]
error_log = {{RFILE:LOG:ERR}}
pid = {{RFILE:PID}}
[unconfined]
listen = {{ADDR}}
access.log = {{RFILE:LOG:ACC}}
access.format = "'%m %r%Q%q' %s"
pm = static
pm.max_children = 2
EOT;
$prefix = __DIR__;
$tester = new FPM\Tester($cfg, $src);
$tester->start(['--prefix', $prefix]);
$tester->expectLogStartNotices();
$response = $tester->request()->expectBody('OK');
$response->expectNoError();
$tester->expectAccessLog("'GET /gh19989-access-log-fcgi-stderr.src.php' 200");
$tester->terminate();
$tester->expectLogTerminatingNotices();
$tester->close();
$tester->checkAccessLog();
?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>