Flush database changes before invoking "mailpoet_segment_subscribed" hook

This is to ensure the hook consumers can read up-to-date data from the database.

[MAILPOET-4946]
This commit is contained in:
Jan Jakes
2023-02-16 14:15:48 +01:00
committed by Aschepikov
parent c3656829a7
commit 6f0307be95

View File

@ -111,6 +111,7 @@ class SubscriberSegmentRepository extends Repository {
$subscriber->getSubscriberSegments()->add($subscriberSegment);
$this->entityManager->persist($subscriberSegment);
}
$this->entityManager->flush();
// fire subscribed hook for new subscriptions
if (
@ -122,7 +123,6 @@ class SubscriberSegmentRepository extends Repository {
$this->wp->doAction('mailpoet_segment_subscribed', $subscriberSegment);
}
$this->entityManager->flush();
return $subscriberSegment;
}
}