Skip to content

Commit

Permalink
Fallback to native entity if no revision found for properties
Browse files Browse the repository at this point in the history
If an audited entity has relational properties, the reader will
try to find them as the same version, or previous.

But if the targeted class does not has any revision at all, this
produces a NoRevisionFound exception.

This should be catched and should fallback to a classic doctrine find query.
  • Loading branch information
soullivaneuh committed Oct 4, 2016
1 parent b5be02a commit 3539c02
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/SimpleThings/EntityAudit/AuditReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@ private function createEntity($className, array $columnMap, array $data, $revisi
$value = $this->find($targetClass->name, $pk, $revision, array('threatDeletionsAsExceptions' => true));
} catch (DeletedException $e) {
$value = null;
} catch (NoRevisionFoundException $e) {
// The entity does not have any revision yet. So let's get the actual state of it.
$value = $this->em->find($targetClass->name, $pk);
}

$class->reflFields[$field]->setValue($entity, $value);
Expand Down

0 comments on commit 3539c02

Please sign in to comment.