diff --git a/mailpoet/lib/Form/FormsRepository.php b/mailpoet/lib/Form/FormsRepository.php index a3cd0b4474..181a4f5608 100644 --- a/mailpoet/lib/Form/FormsRepository.php +++ b/mailpoet/lib/Form/FormsRepository.php @@ -96,10 +96,17 @@ class FormsRepository extends Repository { return 0; } - return $this->entityManager->createQueryBuilder() + $result = $this->entityManager->createQueryBuilder() ->delete(FormEntity::class, 'f') ->where('f.id IN (:ids)') ->setParameter('ids', $ids) ->getQuery()->execute(); + + // delete was done via DQL, make sure the entities are also detached from the entity manager + $this->detachAll(function (FormEntity $entity) use ($ids) { + return in_array($entity->getId(), $ids, true); + }); + + return $result; } } diff --git a/mailpoet/lib/Newsletter/Sending/SendingQueuesRepository.php b/mailpoet/lib/Newsletter/Sending/SendingQueuesRepository.php index 533712383c..f6da88c5f8 100644 --- a/mailpoet/lib/Newsletter/Sending/SendingQueuesRepository.php +++ b/mailpoet/lib/Newsletter/Sending/SendingQueuesRepository.php @@ -167,6 +167,11 @@ class SendingQueuesRepository 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 (SendingQueueEntity $entity) use ($scheduledTask) { + return $entity->getTask() === $scheduledTask; + }); } public function saveCampaignId(SendingQueueEntity $queue, string $campaignId): void {