Skip to content

Commit

Permalink
MongoQuerySerializer: better maxDepth
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mhvis committed Jan 6, 2025
1 parent 5bc6b92 commit 2e2d2c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/DataCollector/MongoQuerySerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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) {
Expand Down

0 comments on commit 2e2d2c2

Please sign in to comment.