8000 Remove normalizer cache in Serializer class · symfony/symfony@57f572d · GitHub
[go: up one dir, main page]

Skip to content

Commit 57f572d

Browse files
committed
Remove normalizer cache in Serializer class
1 parent 7660fb8 commit 57f572d

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

src/Symfony/Component/Serializer/Serializer.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
4040
protected $encoder;
4141
protected $decoder;
4242
protected $normalizers = array();
43-
protected $normalizerCache = array();
44-
protected $denormalizerCache = array();
4543

4644
public function __construct(array $normalizers = array(), array $encoders = array())
4745
{
@@ -229,21 +227,15 @@ private function normalizeObject($object, $format = null, array $context = array
229227
throw new LogicException('You must register at least one normalizer to be able to normalize objects.');
230228
}
231229

232-
$class = get_class($object);
233-
if (isset($this->normalizerCache[$class][$format])) {
234-
return $this->normalizerCache[$class][$format]->normalize($object, $format, $context);
235-
}
236-
237230
foreach ($this->normalizers as $normalizer) {
238231
if ($normalizer instanceof NormalizerInterface
239232
&& $normalizer->supportsNormalization($object, $format)) {
240-
$this->normalizerCache[$class][$format] = $normalizer;
241233

242234
return $normalizer->normalize($object, $format, $context);
243235
}
244236
}
245237

246-
throw new UnexpectedValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', $class));
238+
throw new UnexpectedValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', get_class($object)));
247239
}
248240

249241
/**
@@ -265,14 +257,9 @@ private function denormalizeObject($data, $class, $format = null, array $context
265257
throw new LogicException('You must register at least one normalizer to be able to denormalize objects.');
266258
}
267259

268-
if (isset($this->denormalizerCache[$class][$format])) {
269-
return $this->denormalizerCache[$class][$format]->denormalize($data, $class, $format, $context);
270-
}
271-
272260
foreach ($this->normalizers as $normalizer) {
273261
if ($normalizer instanceof DenormalizerInterface
274262
&& $normalizer->supportsDenormalization($data, $class, $format)) {
275-
$this->denormalizerCache[$class][$format] = $normalizer;
276263

277264
return $normalizer->denormalize($data, $class, $format, $context);
278265
}

0 commit comments

Comments
 (0)
0