From 73876ace6515bac4a3cb568eb73b277f82be6a2c Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 26 Nov 2015 02:33:02 -0600 Subject: [PATCH] Changed iterating over the $handlers array to allow for correct sequential processing regardless of array containing indexed numerical keys, or associative string keys in the array. It iterates over the entire array until it finds the $handlerKey that was identified earlier using isHandling(). Once the starting position is found it will execute handle() on each handler unless a handler returns true indicating the handler completed the processing of the record, bubbling to the next handler should not occur, and the loop breaks. This fixes an issue where an associative array of handlers is passed into the Logger constructor when instantiated. magento/magento2#2529 Seldaek/monolog#691 --- src/Monolog/Logger.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Monolog/Logger.php b/src/Monolog/Logger.php index c52d9876..de79b2f9 100644 --- a/src/Monolog/Logger.php +++ b/src/Monolog/Logger.php @@ -315,9 +315,17 @@ class Logger implements LoggerInterface foreach ($this->processors as $processor) { $record = call_user_func($processor, $record); } - while (isset($this->handlers[$handlerKey]) && - false === $this->handlers[$handlerKey]->handle($record)) { - $handlerKey++; + $foundStartingKey = false; + foreach ($this->handlers as $key => $handler) { + if ($key === $handlerKey) { + $foundStartingKey = true; + } + if ($foundStartingKey === false) { + continue; + } + if (true === $handler->handle($record)) { + break; + } } return true;