Use Doctrine references when saving links
This commit changes the code of the method \MailPoet\Newsletter\Links\Links::save() to use Doctrine references instead of full entities when getting a newsletter and sending queue entities to save the related links. We don't need the full entities here, and getting a full entity for the sending queue was generating an error in the testItLogsErrorWhenNewlyRenderedNewsletterBodyIsInvalid() integration test (see the description of PR https://github.com/mailpoet/mailpoet/pull/3784 for more details). To be able to get the reference, it was necessary to add a helper method called getReference() to \MailPoet\Doctrine\Repository. [MAILPOET-3816]
This commit is contained in:
@@ -103,6 +103,10 @@ abstract class Repository {
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
public function getReference($id) {
|
||||
return $this->entityManager->getReference($this->getEntityClassName(), $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param T $entity
|
||||
*/
|
||||
|
@@ -169,8 +169,8 @@ class Links {
|
||||
continue;
|
||||
}
|
||||
|
||||
$newsletter = $this->newslettersRepository->findOneById($newsletterId);
|
||||
$sendingQueue = $this->sendingQueueRepository->findOneById($queueId);
|
||||
$newsletter = $this->newslettersRepository->getReference($newsletterId);
|
||||
$sendingQueue = $this->sendingQueueRepository->getReference($queueId);
|
||||
|
||||
if (!$newsletter instanceof NewsletterEntity || !$sendingQueue instanceof SendingQueueEntity) {
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user