From a6116398a8c46c641568f0b8b43659f8d00336bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 5 Jan 2025 17:37:02 +0100 Subject: [PATCH] Only run PartDenormalizer when importing files, otherwise it causes problems with API platform This fixes issue #800 --- src/Serializer/PartNormalizer.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Serializer/PartNormalizer.php b/src/Serializer/PartNormalizer.php index 650b0214..e527548f 100644 --- a/src/Serializer/PartNormalizer.php +++ b/src/Serializer/PartNormalizer.php @@ -94,7 +94,14 @@ class PartNormalizer implements NormalizerInterface, DenormalizerInterface, Norm public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool { - return !isset($context[self::ALREADY_CALLED]) && is_array($data) && is_a($type, Part::class, true); + //Only denormalize if we are doing a file import operation + if (!($context['partdb_import'] ?? false)) { + return false; + } + + //Only make the denormalizer available on import operations + return !isset($context[self::ALREADY_CALLED]) + && is_array($data) && is_a($type, Part::class, true); } private function normalizeKeys(array &$data): array