From 5ecfbc25deed6bb7eaa408c46453356d799edd4b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 20 May 2016 19:39:35 +0100 Subject: [PATCH] Fix issue in handling of broken iterators when serializing stack frames, fixes #772 --- src/Monolog/Formatter/JsonFormatter.php | 3 +++ src/Monolog/Formatter/NormalizerFormatter.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/Monolog/Formatter/JsonFormatter.php b/src/Monolog/Formatter/JsonFormatter.php index 06e9d13d..a985e2ab 100644 --- a/src/Monolog/Formatter/JsonFormatter.php +++ b/src/Monolog/Formatter/JsonFormatter.php @@ -186,6 +186,9 @@ class JsonFormatter extends NormalizerFormatter foreach ($trace as $frame) { if (isset($frame['file'])) { $data['trace'][] = $frame['file'].':'.$frame['line']; + } elseif (isset($frame['function']) && $frame['function'] === '{closure}') { + // We should again normalize the frames, because it might contain invalid items + $data['trace'][] = $frame['function']; } else { // We should again normalize the frames, because it might contain invalid items $data['trace'][] = $this->normalize($frame); diff --git a/src/Monolog/Formatter/NormalizerFormatter.php b/src/Monolog/Formatter/NormalizerFormatter.php index a76e2aed..8dec46e4 100644 --- a/src/Monolog/Formatter/NormalizerFormatter.php +++ b/src/Monolog/Formatter/NormalizerFormatter.php @@ -131,6 +131,9 @@ class NormalizerFormatter implements FormatterInterface foreach ($trace as $frame) { if (isset($frame['file'])) { $data['trace'][] = $frame['file'].':'.$frame['line']; + } elseif (isset($frame['function']) && $frame['function'] === '{closure}') { + // We should again normalize the frames, because it might contain invalid items + $data['trace'][] = $frame['function']; } else { // We should again normalize the frames, because it might contain invalid items $data['trace'][] = $this->toJson($this->normalize($frame), true);