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 {
|
||||
|
Reference in New Issue
Block a user