Merge branch '1.14' into 2.0

* 1.14:
  [ApiBundle][Image] Prevent resolving non-serialized image paths
This commit is contained in:
Grzegorz Sadowski 2024-10-23 15:44:53 +02:00
commit f538917c4b
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
2 changed files with 24 additions and 1 deletions

View file

@ -47,7 +47,10 @@ class ImageNormalizer implements NormalizerInterface, NormalizerAwareInterface
/** @var array<string, string> $data */
$data = $this->normalizer->normalize($object, $format, $context);
$data['path'] = $this->resolvePath($data);
if (true === array_key_exists('path', $data)) {
$data['path'] = $this->resolvePath($data);
}
return $data;
}

View file

@ -166,6 +166,26 @@ final class ImageNormalizerSpec extends ObjectBehavior
;
}
function it_does_not_resolve_image_path_if_path_is_not_serialized(
CacheManager $cacheManager,
RequestStack $requestStack,
NormalizerInterface $normalizer,
Request $request,
ParameterBag $queryBag,
ImageInterface $image,
): void {
$normalizer
->normalize($image, null, ['sylius_image_normalizer_already_called' => true])
->shouldBeCalled()
->willReturn(['id' => 1])
;
$this->normalize($image, null, [])->shouldReturn(['id' => 1]);
$cacheManager->getBrowserPath(Argument::any(), Argument::any())->shouldNotHaveBeenCalled();
$requestStack->getCurrentRequest()->shouldNotHaveBeenCalled();
}
function it_applies_given_image_filter(
CacheManager $cacheManager,
RequestStack $requestStack,