Skip to content

Commit a4d57f2

Browse files
committed
Revert double checks - no difference
1 parent 25afa54 commit a4d57f2

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/Serializer/Normalizer/PublishableNormalizer.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,8 @@ public function denormalize($data, $type, $format = null, array $context = []):
173173

174174
// Any field has been modified: create a draft
175175
// if we sent 2 simultaneous requests then the initial sql query will have got the live version even if there is a draft now, so let's re-check before creating
176-
$em = $this->getManagerFromType($type);
177-
$em->refresh($object);
178-
$configuration = $this->publishableStatusChecker->getAttributeReader()->getConfiguration($type);
179-
$em = $this->getManagerFromType($type);
180-
$classMetadata = $this->getClassMetadataInfo($em, $type);
181-
$draft = $classMetadata->getFieldValue($object, $configuration->reverseAssociationName);
182-
if (!$draft) {
183-
$draft = $this->createDraft($object, $configuration, $type);
184-
}
176+
// todo: perhaps lock the database ona request for each resource? Or when we come to create a draft and then refresh / re-lookup the published resource here knowing it'll wait until the lock is over
177+
$draft = $this->createDraft($object, $configuration, $type);
185178
$context[AbstractNormalizer::OBJECT_TO_POPULATE] = $draft;
186179

187180
return $this->denormalizer->denormalize($data, $type, $format, $context);
@@ -254,9 +247,6 @@ public function createDraft(object $object, Publishable $configuration, string $
254247
// Add draft object to UnitOfWork
255248
$em->persist($draft);
256249

257-
// todo: perhaps we need to flush here so if we get another request before flushed, we do not get a duplicate key sql error trying to create a draft when one already exists
258-
$em->flush($draft);
259-
260250
// Clear the cache of the published resource because it should now also return an associated draft
261251
$event = new ResourceChangedEvent($object, 'updated');
262252
$this->eventDispatcher->dispatch($event);

0 commit comments

Comments
 (0)