diff options
| author | 2023-01-30 20:31:46 +0100 | |
|---|---|---|
| committer | 2023-01-30 20:31:46 +0100 | |
| commit | 4ad66c24bfd96a5f5a71eec895e9d3085d67f4a0 (patch) | |
| tree | 2e712b79a1549d7802526f2314c519e601a9f0d5 | |
| parent | 9e4b4c90722812dd6c98699513180eb90cb57bb1 (diff) | |
Workaround disabled openlog syslog (#5054)
* Workaround disabled openlog syslog
#fix https://github.com/FreshRSS/FreshRSS/issues/5053
#fix https://github.com/FreshRSS/FreshRSS/issues/5027
* COPY_SYSLOG_TO_STDERR
* Better return
* Simplify openlog
| -rw-r--r-- | lib/lib_rss.php | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 893bed8eb..f648d7cd2 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -16,11 +16,27 @@ if (!function_exists('str_starts_with')) { } } -// @phpstan-ignore-next-line -if (COPY_SYSLOG_TO_STDERR) { - openlog('FreshRSS', LOG_CONS | LOG_ODELAY | LOG_PID | LOG_PERROR, LOG_USER); -} else { - openlog('FreshRSS', LOG_CONS | LOG_ODELAY | LOG_PID, LOG_USER); +if (!function_exists('syslog')) { + // @phpstan-ignore-next-line + if (COPY_SYSLOG_TO_STDERR && !defined('STDERR')) { + define('STDERR', fopen('php://stderr', 'w')); + } + function syslog(int $priority, string $message): bool { + // @phpstan-ignore-next-line + if (COPY_SYSLOG_TO_STDERR && defined('STDERR') && STDERR) { + return fwrite(STDERR, $message . "\n") != false; + } + return false; + } +} + +if (function_exists('openlog')) { + // @phpstan-ignore-next-line + if (COPY_SYSLOG_TO_STDERR) { + openlog('FreshRSS', LOG_CONS | LOG_ODELAY | LOG_PID | LOG_PERROR, LOG_USER); + } else { + openlog('FreshRSS', LOG_CONS | LOG_ODELAY | LOG_PID, LOG_USER); + } } /** |
