diff --git a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Links.php b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Links.php index 89ece3f259..c33e1a4ed0 100644 --- a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Links.php +++ b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Links.php @@ -3,6 +3,7 @@ namespace MailPoet\Cron\Workers\SendingQueue\Tasks; use MailPoet\Cron\Workers\StatsNotifications\NewsletterLinkRepository; +use MailPoet\Entities\NewsletterEntity; use MailPoet\Entities\NewsletterLinkEntity; use MailPoet\Newsletter\Links\Links as NewsletterLinks; use MailPoet\Router\Endpoints\Track; @@ -43,8 +44,8 @@ class Links { $this->trackingConfig = $trackingConfig; } - public function process($renderedNewsletter, $newsletter, $queue) { - [$renderedNewsletter, $links] = $this->hashAndReplaceLinks($renderedNewsletter, $newsletter->id, $queue->id); + public function process($renderedNewsletter, NewsletterEntity $newsletter, $queue) { + [$renderedNewsletter, $links] = $this->hashAndReplaceLinks($renderedNewsletter, $newsletter->getId(), $queue->id); $this->saveLinks($links, $newsletter, $queue); return $renderedNewsletter; } @@ -63,8 +64,8 @@ class Links { ]; } - public function saveLinks($links, $newsletter, $queue) { - return $this->newsletterLinks->save($links, $newsletter->id, $queue->id); + public function saveLinks($links, NewsletterEntity $newsletter, $queue) { + return $this->newsletterLinks->save($links, $newsletter->getId(), $queue->id); } public function getUnsubscribeUrl($queue, $subscriberId) { diff --git a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Newsletter.php b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Newsletter.php index b3e576d1e4..8296046d94 100644 --- a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Newsletter.php +++ b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Newsletter.php @@ -150,7 +150,7 @@ class Newsletter { ); $renderedNewsletter = $this->gaTracking->applyGATracking($renderedNewsletter, $newsletterEntity); // hash and save all links - $renderedNewsletter = $this->linksTask->process($renderedNewsletter, $newsletter, $sendingTask); + $renderedNewsletter = $this->linksTask->process($renderedNewsletter, $newsletterEntity, $sendingTask); } else { // render newsletter $renderedNewsletter = $this->renderer->render($newsletterEntity, $sendingTask); diff --git a/mailpoet/tests/integration/Cron/Workers/SendingQueue/Tasks/LinksTest.php b/mailpoet/tests/integration/Cron/Workers/SendingQueue/Tasks/LinksTest.php index bfe04b1839..5b9b0723d7 100644 --- a/mailpoet/tests/integration/Cron/Workers/SendingQueue/Tasks/LinksTest.php +++ b/mailpoet/tests/integration/Cron/Workers/SendingQueue/Tasks/LinksTest.php @@ -38,10 +38,9 @@ class LinksTest extends \MailPoetTest { 'hash' => 'some_hash', ], ]; - $newsletter = (object)['id' => $this->newsletter->getId()]; $queue = (object)['id' => $this->queue->getId()]; - $this->links->saveLinks($links, $newsletter, $queue); + $this->links->saveLinks($links, $this->newsletter, $queue); $newsletterLink = $this->newsletterLinkRepository->findOneBy(['hash' => $links[0]['hash']]); assert($newsletterLink instanceof NewsletterLinkEntity);