mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Fixed infinite loop during deserialization on attachment PATCH operations
This commit is contained in:
parent
3734541743
commit
0824e11570
1 changed files with 10 additions and 3 deletions
|
@ -48,6 +48,8 @@ class DetermineTypeFromElementIRIDenormalizer implements DenormalizerInterface,
|
|||
|
||||
use DenormalizerAwareTrait;
|
||||
|
||||
private const ALREADY_CALLED = self::class . '::ALREADY_CALLED';
|
||||
|
||||
public function __construct(private readonly IriConverterInterface $iriConverter, private readonly ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory)
|
||||
{
|
||||
}
|
||||
|
@ -94,13 +96,18 @@ class DetermineTypeFromElementIRIDenormalizer implements DenormalizerInterface,
|
|||
$data = $this->addTypeDiscriminatorIfNecessary($data, $context['operation']);
|
||||
}
|
||||
|
||||
$context[self::ALREADY_CALLED] = true;
|
||||
|
||||
return $this->denormalizer->denormalize($data, $type, $format, $context);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(mixed $data, string $type, ?string $format = null)
|
||||
public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = [])
|
||||
{
|
||||
//Only denormalize if the _type discriminator is not set and the class is supported
|
||||
return is_array($data) && !isset($data['_type']) && in_array($type, self::SUPPORTED_CLASSES, true);
|
||||
//Only denormalize if the _type discriminator is not set and the class is supported and we not have already called this function
|
||||
return !isset($context[self::ALREADY_CALLED])
|
||||
&& is_array($data)
|
||||
&& !isset($data['_type'])
|
||||
&& in_array($type, self::SUPPORTED_CLASSES, true);
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue