diff --git a/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php b/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php index 1f19def23..9a61043ff 100644 --- a/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php @@ -46,10 +46,12 @@ class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberIn private function persistNotifications(): void { - foreach ($this->persister->getWaitingNotifications() as $notification) { - $this->em->persist($notification); - } + if (0 < count($this->persister->getWaitingNotifications())) { + foreach ($this->persister->getWaitingNotifications() as $notification) { + $this->em->persist($notification); + } - $this->em->flush(); + $this->em->flush(); + } } }