Skip to content

Commit

Permalink
[framework] EntityLogEventListener now handles PersistentCollection d…
Browse files Browse the repository at this point in the history
…irectly instead of catching Exception (#3374)

Co-authored-by: Milan Staňo <milan.stano@shopsys.com>
  • Loading branch information
stanoMilan and msshopsys authored Sep 2, 2024
1 parent c00fd04 commit 5d1cdf1
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\ORM\Event\PostPersistEventArgs;
use Doctrine\ORM\Event\PostUpdateEventArgs;
use Doctrine\ORM\Event\PreRemoveEventArgs;
use Doctrine\ORM\PersistentCollection;
use Psr\Log\LoggerInterface;
use Shopsys\FrameworkBundle\Component\EntityLog\Attribute\LoggableEntityConfig;
use Shopsys\FrameworkBundle\Component\EntityLog\Attribute\LoggableEntityConfigFactory;
Expand Down Expand Up @@ -156,6 +157,12 @@ protected function resolveUpdateChangeSet(object $entity): array

$changeSet = $unitOfWork->getEntityChangeSet($entity);

foreach ($changeSet as $key => $value) {
if ($value instanceof PersistentCollection) {
unset($changeSet[$key]); //collection is logged in resolveChangesOnCollectionForEntity method
}
}

if (count($changeSet) > 0) {
$resolvedChangeSet = array_merge($resolvedChangeSet, $this->changeSetResolver->resolveChangeSetForEntity($changeSet, $entity));
}
Expand Down

0 comments on commit 5d1cdf1

Please sign in to comment.