From f7e60c34565d643abc8d3d1db4db54389dd93b59 Mon Sep 17 00:00:00 2001 From: Alexandre Bertrand Date: Mon, 13 May 2024 09:57:23 +0200 Subject: [PATCH] Enable max depth for Symfony serializer too (#1935) --- src/Serializer/Callback.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Serializer/Callback.php b/src/Serializer/Callback.php index 27f6b6134..44b8a6c14 100644 --- a/src/Serializer/Callback.php +++ b/src/Serializer/Callback.php @@ -13,6 +13,7 @@ use JMS\Serializer\SerializationContext; use JMS\Serializer\SerializerInterface as JMSSerializer; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Symfony\Component\Serializer\SerializerInterface; class Callback @@ -83,7 +84,7 @@ public function setSerializeNull(bool $serializeNull): self public function serialize($object): string { - $context = $this->serializer instanceof JMSSerializer ? SerializationContext::create()->enableMaxDepthChecks() : []; + $context = $this->serializer instanceof JMSSerializer ? SerializationContext::create()->enableMaxDepthChecks() : [AbstractObjectNormalizer::ENABLE_MAX_DEPTH => true]; if (!empty($this->groups)) { if ($context instanceof SerializationContext) {