Use refreshAll() helper for batch updates
[MAILPOET-5845]
This commit is contained in:
@@ -69,12 +69,19 @@ class FormsRepository extends Repository {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->entityManager->createQueryBuilder()
|
||||
$result = $this->entityManager->createQueryBuilder()
|
||||
->update(FormEntity::class, 'f')
|
||||
->set('f.deletedAt', 'CURRENT_TIMESTAMP()')
|
||||
->where('f.id IN (:ids)')
|
||||
->setParameter('ids', $ids)
|
||||
->getQuery()->execute();
|
||||
|
||||
// update was done via DQL, make sure the entities are also refreshed in the entity manager
|
||||
$this->refreshAll(function (FormEntity $entity) use ($ids) {
|
||||
return in_array($entity->getId(), $ids, true);
|
||||
});
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function bulkRestore(array $ids): int {
|
||||
@@ -82,13 +89,20 @@ class FormsRepository extends Repository {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->entityManager->createQueryBuilder()
|
||||
$result = $this->entityManager->createQueryBuilder()
|
||||
->update(FormEntity::class, 'f')
|
||||
->set('f.deletedAt', ':deletedAt')
|
||||
->where('f.id IN (:ids)')
|
||||
->setParameter('deletedAt', null)
|
||||
->setParameter('ids', $ids)
|
||||
->getQuery()->execute();
|
||||
|
||||
// update was done via DQL, make sure the entities are also refreshed in the entity manager
|
||||
$this->refreshAll(function (FormEntity $entity) use ($ids) {
|
||||
return in_array($entity->getId(), $ids, true);
|
||||
});
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function bulkDelete(array $ids): int {
|
||||
|
@@ -94,6 +94,11 @@ class ScheduledTaskSubscribersRepository extends Repository {
|
||||
->setParameter('task', $task)
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
// update was done via DQL, make sure the entities are also refreshed in the entity manager
|
||||
$this->refreshAll(function (ScheduledTaskSubscriberEntity $entity) use ($task, $subscriberIds) {
|
||||
return $entity->getTask() === $task && in_array($entity->getSubscriberId(), $subscriberIds, true);
|
||||
});
|
||||
}
|
||||
|
||||
$this->checkCompleted($task);
|
||||
|
@@ -308,6 +308,11 @@ class ScheduledTasksRepository extends Repository {
|
||||
->setParameter('ids', $ids, Connection::PARAM_INT_ARRAY)
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
// update was done via DQL, make sure the entities are also refreshed in the entity manager
|
||||
$this->refreshAll(function (ScheduledTaskEntity $entity) use ($ids) {
|
||||
return in_array($entity->getId(), $ids, true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user