Use orphan removal for scheduled task subscriber entity

It is a connecting entity between task and subscriber, and it makes no sense
to keep without either of them. This could prevent some partial-delete bugs.

[MAILPOET-4375]
This commit is contained in:
Jan Jakes
2023-10-26 15:25:20 +02:00
committed by Aschepikov
parent b734a0642f
commit 8b01360627
3 changed files with 16 additions and 2 deletions

View File

@@ -95,8 +95,15 @@ class ScheduledTaskEntity {
*/
private $sendingQueue;
/**
* @ORM\OneToMany(targetEntity="MailPoet\Entities\ScheduledTaskSubscriberEntity", mappedBy="task", orphanRemoval=true)
* @var Collection<int, ScheduledTaskSubscriberEntity>
*/
private $scheduledTaskSubscribers;
public function __construct() {
$this->subscribers = new ArrayCollection();
$this->scheduledTaskSubscribers = new ArrayCollection();
}
/**

View File

@@ -45,13 +45,13 @@ class ScheduledTaskSubscriberEntity {
private $error;
/**
* @ORM\Id @ORM\ManyToOne(targetEntity="MailPoet\Entities\ScheduledTaskEntity")
* @ORM\Id @ORM\ManyToOne(targetEntity="MailPoet\Entities\ScheduledTaskEntity", inversedBy="scheduledTaskSubscribers")
* @var ScheduledTaskEntity|null
*/
private $task;
/**
* @ORM\Id @ORM\ManyToOne(targetEntity="MailPoet\Entities\SubscriberEntity")
* @ORM\Id @ORM\ManyToOne(targetEntity="MailPoet\Entities\SubscriberEntity", inversedBy="scheduledTaskSubscribers")
* @var SubscriberEntity|null
*/
private $subscriber;

View File

@@ -215,10 +215,17 @@ class SubscriberEntity {
*/
private $subscriberTags;
/**
* @ORM\OneToMany(targetEntity="MailPoet\Entities\ScheduledTaskSubscriberEntity", mappedBy="subscriber", orphanRemoval=true)
* @var Collection<int, ScheduledTaskSubscriberEntity>
*/
private $scheduledTaskSubscribers;
public function __construct() {
$this->subscriberSegments = new ArrayCollection();
$this->subscriberCustomFields = new ArrayCollection();
$this->subscriberTags = new ArrayCollection();
$this->scheduledTaskSubscribers = new ArrayCollection();
}
/**