Sync bulk deletes of scheduled task subscribers to entity manager

Fixes: https://github.com/mailpoet/mailpoet/issues/5281

[MAILPOET-5745]
This commit is contained in:
Jan Jakes
2023-11-28 16:01:10 +01:00
committed by Aschepikov
parent 076ee6d5de
commit 45f5803293
2 changed files with 10 additions and 4 deletions

View File

@@ -124,6 +124,11 @@ class ScheduledTaskSubscribersRepository extends Repository {
->setParameter('task', $scheduledTask)
->getQuery()
->execute();
// delete was done via DQL, make sure the entities are also detached from the entity manager
$this->detachAll(function (ScheduledTaskSubscriberEntity $entity) use ($scheduledTask) {
return $entity->getTask() === $scheduledTask;
});
}
public function deleteByScheduledTaskAndSubscriberIds(ScheduledTaskEntity $scheduledTask, array $subscriberIds): void {
@@ -136,6 +141,11 @@ class ScheduledTaskSubscribersRepository extends Repository {
->getQuery()
->execute();
// delete was done via DQL, make sure the entities are also detached from the entity manager
$this->detachAll(function (ScheduledTaskSubscriberEntity $entity) use ($scheduledTask, $subscriberIds) {
return $entity->getTask() === $scheduledTask && in_array($entity->getSubscriberId(), $subscriberIds, true);
});
$this->checkCompleted($scheduledTask);
}