Skip to content

Multiple newsletter confirmation emails sent #12876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nfourteen opened this issue Dec 25, 2017 · 8 comments
Closed

Multiple newsletter confirmation emails sent #12876

nfourteen opened this issue Dec 25, 2017 · 8 comments
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@nfourteen
Copy link
Contributor

Preconditions

  1. Magento 2.2.1
  2. Php 7.0

Steps to reproduce

  1. Change configuration under Stores > Configuration > Customers > Newsletter > Subscription Options > Need to Confirm to Yes
  2. Sign up for Newsletter on frontend as a guest
  3. Follow confirmation link in email
  4. Create an account and check Sign Up for Newsletter within the form and use the same email as in Step 2

Expected result

There are a couple different results that I'll leave to the Magento core team:

  1. If someone signed up for a Newsletter subscription as a guest, have confirmed that subscription, and then create an account with the same email—then the Magento application could update the Newsletter Subscribers with the customer data and leave the status as Subscribed, thus no Need to Confirm email is sent since they've already confirmed they wanted to receive the newsletter.
  2. The Magento application could change the guest email status to STATUS_UNCONFIRMED, update the guest email with the customer data, and send the Need to Confirm email for the new account.

Actual result

  1. Three Need to Confirm emails are received.

Reason

The first two emails are received because of the \Magento\Newsletter\Model\Plugin\CustomerPlugin::afterSave() method. When \Magento\Customer\Controller\Account\CreatePost::execute() is called a new customer account is created on line 313 with \Magento\Customer\Model\AccountManagement::createAccount(). The createAccount() method calls createAccountWithPasswordHash() whereby the customer is saved on line 748 and then that same method calls $this->changeResetPasswordLinkToken() on line 775, which again saves the customer on line 1242. Thus these two customer saves trigger the afterSave() method calls on the CustomerPlugin, which updates the subscription and sends the two emails.

The third and final email is received within the Magento\Customer\Controller\Account\CreatePost::execute() method on line 317 when the is_subscribed param is retrieved from the form data within the request and the if conditional equals true because of Step 4 above.

@magento-engcom-team magento-engcom-team added Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Dec 25, 2017
@magento-engcom-team
Copy link
Contributor

@nfourteen, thank you for your report.
We've created internal ticket(s) MAGETWO-85994 to track progress on the issue.

@serhii-balko serhii-balko self-assigned this Dec 29, 2017
@matthiashamacher
Copy link

Hello,
We have a similar issue with the newsletter.
When the customer wants a new password (Forgot Your Password?) and when he changes his password after clicking the link in the reset E-Mail, he must confirm the newsletter another time. The confirmed newsletter subscriptions were unsubscripted.
A workaround for this is to deactivate the function "Need to Confirm".

@serhii-balko
Copy link
Contributor

Hi @matthiashama
My pull request may be fix it.

@matthiashamacher
Copy link

Hi @serhii-balko
Are you still work on it? Or where do I find your pull request?

@serhii-balko
Copy link
Contributor

serhii-balko commented Jan 3, 2018

Yes, it will be merged after a while
https://github.com/magento-engcom/magento2ce/pull/1139

@torhoehn
Copy link
Contributor

torhoehn commented Jan 3, 2018

@serhii-balko You created a pull request to a private repository. You should create your pull request for this public repository and inside of your PR you should mention this issue. So it'll be linked automatically.

@magento-team
Copy link
Contributor

Hi @nfourteen. Thank you for your report.
The issue has been fixed in #13044 by @torhoehn in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming patch release.

@magento-team magento-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jan 11, 2018
@serhii-balko serhii-balko removed their assignment Jan 15, 2018
@magento-engcom-team
Copy link
Contributor

Hi @nfourteen. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1351 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Feb 6, 2018
@magento magento deleted a comment from dayfinder Sep 25, 2019
@magento magento deleted a comment from dayfinder Sep 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

6 participants