From 2e2d2c247f86c92453f62e00d05f9657b8af2655 Mon Sep 17 00:00:00 2001 From: Maarten Visscher Date: Mon, 6 Jan 2025 15:46:24 +0100 Subject: [PATCH] MongoQuerySerializer: better maxDepth The maxDepth of 256 still triggered a stack overflow because our maximum stack size was 512 and the stack grows by 2 during each recursion. The 50 chosen here is arbitrary. --- src/DataCollector/MongoQuerySerializer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DataCollector/MongoQuerySerializer.php b/src/DataCollector/MongoQuerySerializer.php index 1d195fa..0f51ccc 100644 --- a/src/DataCollector/MongoQuerySerializer.php +++ b/src/DataCollector/MongoQuerySerializer.php @@ -24,7 +24,7 @@ public static function serialize(Query $query): void * * @return mixed[] */ - private static function prepareUnserializableData($data, int $maxDepth = 256): array + private static function prepareUnserializableData($data, int $maxDepth = 50): array { if ($data instanceof Serializable) { $data = $data->bsonSerialize(); @@ -43,7 +43,7 @@ private static function prepareUnserializableData($data, int $maxDepth = 256): a * * @return mixed */ - public static function prepareItemData($item, int $maxDepth = 256) + public static function prepareItemData($item, int $maxDepth = 50) { // Prevent infinite recursion if ($maxDepth < 0) {