1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-22 17:16:18 +02:00

Merge pull request #808 from naderman/fix/normalizer-recusion

Normalization of arrays containing self references
This commit is contained in:
Jordi Boggiano
2016-07-02 15:34:40 +02:00
committed by GitHub
4 changed files with 23 additions and 6 deletions

View File

@@ -135,8 +135,12 @@ class JsonFormatter extends NormalizerFormatter
*
* @return mixed
*/
protected function normalize($data)
protected function normalize($data, $depth = 0)
{
if ($depth > 9) {
return 'Over 9 levels deep, aborting normalization';
}
if (is_array($data) || $data instanceof \Traversable) {
$normalized = [];
@@ -146,7 +150,7 @@ class JsonFormatter extends NormalizerFormatter
$normalized['...'] = 'Over 1000 items, aborting normalization';
break;
}
$normalized[$key] = $this->normalize($value);
$normalized[$key] = $this->normalize($value, $depth+1);
}
return $normalized;