Skip to content

Commit c5a89f9

Browse files
committed
MC-29102: [2.4.x] [Magento Cloud] Customer receives newsletter unsubscription email after registering for new account
1 parent 41b25c8 commit c5a89f9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

app/code/Magento/Newsletter/Controller/Ajax/Status.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\Action\HttpGetActionInterface;
1111
use Magento\Framework\Controller\Result\Json;
1212
use Magento\Framework\Controller\ResultFactory;
13+
use Magento\Framework\Exception\LocalizedException;
1314
use Magento\Framework\Validator\EmailAddress as EmailAddressValidator;
1415
use Magento\Newsletter\Model\GuestSubscriptionChecker;
1516
use Psr\Log\LoggerInterface;
@@ -67,7 +68,7 @@ public function execute()
6768
if (!empty($email) && $this->emailAddressValidator->isValid($email)) {
6869
$response['subscribed'] = $this->guestSubscriptionChecker->isSubscribed($email);
6970
}
70-
} catch (\Throwable $exception) {
71+
} catch (LocalizedException | \DomainException $exception) {
7172
$this->logger->error($exception->getMessage());
7273
$response['errors'] = true;
7374
}

app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function testAfterSave(?int $originalStatus, ?bool $newValue, ?bool $expe
124124
->method('loadByCustomer')
125125
->with($customerId, $websiteId)
126126
->willReturnSelf();
127-
if ($originalStatus == Subscriber::STATUS_UNCONFIRMED) {
127+
if ($originalStatus !== null && $originalStatus === Subscriber::STATUS_UNCONFIRMED) {
128128
$subscriber->method('getId')->willReturn(1);
129129
} else {
130130
$subscriber->expects($this->once())

0 commit comments

Comments
 (0)