From 6fb32edcd47940c9bba20a92b901308ccffa3f5b Mon Sep 17 00:00:00 2001 From: jnuernberger Date: Fri, 28 Aug 2026 11:09:54 +0200 Subject: [PATCH] fix(logger): accept any Monolog handler as process manager log writer The return value of AbstractLogger::createStreamHandler() is passed straight to ApplicationLogger::addWriter(), which accepts every HandlerInterface implementation. The narrower union StreamHandler|ApplicationLoggerDb|null therefore rules out valid handlers for no reason, in particular every handler that does not write to a stream: the AsyncAws CloudWatch handler, Sentry, Slack, Redis. That the union already contains ApplicationLoggerDb, which is not a StreamHandler, shows the intent was "a log writer", not "a stream". Projects hitting this cannot return their handler at all, because the return type cannot be widened in a child class. Widening it here to ?HandlerInterface is backwards compatible: all existing implementations (File, Console, Application, EmailSummary) keep their narrower return types, which covariance allows. --- src/Executor/Logger/AbstractLogger.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Executor/Logger/AbstractLogger.php b/src/Executor/Logger/AbstractLogger.php index aee6dc9..6450f5a 100644 --- a/src/Executor/Logger/AbstractLogger.php +++ b/src/Executor/Logger/AbstractLogger.php @@ -8,8 +8,7 @@ namespace Elements\Bundle\ProcessManagerBundle\Executor\Logger; use Elements\Bundle\ProcessManagerBundle\Model\MonitoringItem; -use Monolog\Handler\StreamHandler; -use Pimcore\Bundle\ApplicationLoggerBundle\Handler\ApplicationLoggerDb; +use Monolog\Handler\HandlerInterface; abstract class AbstractLogger { @@ -93,9 +92,16 @@ public function setConfig(array $config) abstract public function getGridLoggerHtml(MonitoringItem $monitoringItem, array $actionData): string; /** + * Returns the log writer which is registered on the monitoring item logger. + * + * Any Monolog handler is accepted here, because the return value is passed to + * ApplicationLogger::addWriter(), which handles every HandlerInterface implementation. + * Restricting this to StreamHandler would rule out handlers that do not write to a + * stream, for example the AsyncAws CloudWatch handler. + * * @param array $config * @param MonitoringItem $monitoringItem * */ - abstract public function createStreamHandler(array $config, MonitoringItem $monitoringItem): StreamHandler | ApplicationLoggerDb | null; + abstract public function createStreamHandler(array $config, MonitoringItem $monitoringItem): ?HandlerInterface; }