Ver Fonte

Fix issue in handling of broken iterators when serializing stack frames, fixes #772

Jordi Boggiano há 9 anos atrás
pai
commit
5ecfbc25de

+ 3 - 0
src/Monolog/Formatter/JsonFormatter.php

@@ -186,6 +186,9 @@ class JsonFormatter extends NormalizerFormatter
             foreach ($trace as $frame) {
             foreach ($trace as $frame) {
                 if (isset($frame['file'])) {
                 if (isset($frame['file'])) {
                     $data['trace'][] = $frame['file'].':'.$frame['line'];
                     $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 {
                 } else {
                     // We should again normalize the frames, because it might contain invalid items
                     // We should again normalize the frames, because it might contain invalid items
                     $data['trace'][] = $this->normalize($frame);
                     $data['trace'][] = $this->normalize($frame);

+ 3 - 0
src/Monolog/Formatter/NormalizerFormatter.php

@@ -131,6 +131,9 @@ class NormalizerFormatter implements FormatterInterface
         foreach ($trace as $frame) {
         foreach ($trace as $frame) {
             if (isset($frame['file'])) {
             if (isset($frame['file'])) {
                 $data['trace'][] = $frame['file'].':'.$frame['line'];
                 $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 {
             } else {
                 // We should again normalize the frames, because it might contain invalid items
                 // We should again normalize the frames, because it might contain invalid items
                 $data['trace'][] = $this->toJson($this->normalize($frame), true);
                 $data['trace'][] = $this->toJson($this->normalize($frame), true);