Add newsletter links cleanup to newsletter bulk delete

[MAILPOET-2898]
This commit is contained in:
Rostislav Wolny
2020-06-09 16:45:09 +02:00
committed by Veljko V
parent 5dbc8d8a8c
commit b99416785c
2 changed files with 25 additions and 0 deletions

View File

@ -9,6 +9,7 @@ use MailPoet\AutomaticEmails\WooCommerce\Events\PurchasedInCategory;
use MailPoet\AutomaticEmails\WooCommerce\Events\PurchasedProduct;
use MailPoet\Doctrine\Repository;
use MailPoet\Entities\NewsletterEntity;
use MailPoet\Entities\NewsletterLinkEntity;
use MailPoet\Entities\NewsletterOptionFieldEntity;
use MailPoet\Entities\NewsletterSegmentEntity;
use MailPoet\Entities\ScheduledTaskEntity;
@ -220,6 +221,13 @@ class NewslettersRepository extends Repository {
$sendingQueueTable = $this->entityManager->getClassMetadata(SendingQueueEntity::class)->getTableName();
$scheduledTaskSubscribersTable = $this->entityManager->getClassMetadata(ScheduledTaskSubscriberEntity::class)->getTableName();
// Delete newsletter links
$linksTable = $this->entityManager->getClassMetadata(NewsletterLinkEntity::class)->getTableName();
$this->entityManager->getConnection()->executeUpdate("
DELETE nl FROM $linksTable nl
WHERE nl.`newsletter_id` IN (:ids)
", ['ids' => $ids], ['ids' => Connection::PARAM_INT_ARRAY]);
// Delete stats notifications
$statsNotificationsTable = $this->entityManager->getClassMetadata(StatsNotificationEntity::class)->getTableName();
$this->entityManager->getConnection()->executeUpdate("