Skip to content
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

Incorrect caching subscription status in newsletter plugin #19345

Closed
wojtekn opened this issue Nov 22, 2018 · 13 comments · Fixed by #32254
Closed

Incorrect caching subscription status in newsletter plugin #19345

wojtekn opened this issue Nov 22, 2018 · 13 comments · Fixed by #32254
Assignees
Labels
Component: Customer Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done 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 Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.

Comments

@wojtekn
Copy link
Contributor

wojtekn commented Nov 22, 2018

Preconditions

  1. Magento 2.4-develop

Steps to reproduce

I spot the issue during placing order with two different community modules installed. In short, during placing order the customer object is subscribed by custom code which utilizes newsletter module, then customer object is saved a couple times, and it results with subscribing him, unsubscribing and subscribing again.

It is a bit complicated to prepare such environment and to reproduce it so I prepared short steps which show incorrect framework behavior.

  1. Load customer object using repository and check his subscription status:

    $customer = $customerRepository->getById($customerId);
    $extensionAttributes = $customer->getExtensionAttributes();
    var_dump($extensionAttributes->getIsSubscribed()); // returns false

  2. Subscribe customer to newsletter:

    $subscriber = $subscriberFactory->create();
    $subscriber->subscribeCustomerById($customerId);

  3. Check subscription status again:

    $customer = $customerRepository->getById($customerId);
    $extensionAttributes = $customer->getExtensionAttributes();
    var_dump($extensionAttributes->getIsSubscribed()); // still returns false

Expected result

  1. getIsSubscribed returns true when runs after subscribing customer

Actual result

  1. getIsSubscribed returns false
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Nov 22, 2018
@magento-engcom-team
Copy link
Contributor

Hi @wojtekn. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop).
For more details, please, review the Magento Contributor Assistant documentation.

@wojtekn do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@orlangur
Copy link
Contributor

@wojtekn,

then customer object is saved a couple times

Such problem is not observed when customer is saved using CustomerRepository.

@ghost ghost self-assigned this Nov 23, 2018
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Nov 23, 2018

Hi @engcom-backlog-nazar. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@ghost ghost added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Component: Customer labels Nov 23, 2018
@ghost
Copy link

ghost commented Nov 23, 2018

Hi @wojtekn, Hi @orlangur thank you for your report, in first time when i run this on console command i'm have false, but another time always return true, so problem with registry, when you load customer from repository you have no choise to load from.
selection_215

@ghost ghost added 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 Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Nov 23, 2018
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Nov 23, 2018
@magento-engcom-team
Copy link
Contributor

@engcom-backlog-nazar Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-96607, MAGETWO-96608 were created

@orlangur
Copy link
Contributor

@engcom-backlog-nazar correct, I noticed from subscribeCustomerById implementation that there is no way customer instance may be reloaded. What I was saying is that it is quite easy to circumvent in third-party code.

@ghost
Copy link

ghost commented Nov 23, 2018

@orlangur we need some additional options like in productRepository force Reload = true.
selection_216

@ghost ghost removed their assignment Nov 23, 2018
@orlangur
Copy link
Contributor

@engcom-backlog-nazar introducing such flags is really lame. It would be better if invalidation occurs somewhere inside subscribeCustomerById, we already have push method to achieve this.

@wojtekn
Copy link
Contributor Author

wojtekn commented Nov 27, 2018

@engcom-backlog-nazar I think changing getById implementation to preserve extension attributes also makes sense. It wouldn't solve my use case, but it would fix other ones. Eg. I could write plugin for subscribeCustomerById and fill extension attribute there instead of removing this variable caching in the core file patch.

@orlangur it makes sense IMO.

@milindsingh milindsingh self-assigned this Dec 25, 2018
@magento-engcom-team
Copy link
Contributor

Hi @milindsingh. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@magento-engcom-team magento-engcom-team added this to Ready for Dev in Community Backlog Mar 24, 2020
@sidolov sidolov added this to Ready for Grooming in Low Priority Backlog Sep 3, 2020
@sidolov sidolov added this to Ready for Development in Low Priority Backlog Sep 24, 2020
@ghost ghost removed this from Ready for Dev in Community Backlog Oct 20, 2020
@ghost ghost removed this from Ready for Development in Low Priority Backlog Oct 20, 2020
@m2-community-project m2-community-project bot moved this from Dev In Progress to Ready for Development in High Priority Backlog Feb 23, 2021
@engcom-Charlie engcom-Charlie self-assigned this Feb 23, 2021
@m2-community-project m2-community-project bot moved this from Ready for Development to Dev In Progress in High Priority Backlog Feb 23, 2021
@m2-community-project m2-community-project bot moved this from Dev In Progress to Pull Request In Progress in High Priority Backlog Feb 23, 2021
engcom-Foxtrot added a commit to engcom-Charlie/magento2 that referenced this issue Mar 22, 2021
engcom-Foxtrot added a commit to engcom-Charlie/magento2 that referenced this issue Mar 31, 2021
@gabrieldagama
Copy link
Contributor

Hi @wojtekn. Thank you for your report.
The issue has been fixed in #32254 by @engcom-Charlie in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.3 release.

@gabrieldagama gabrieldagama added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Apr 11, 2021
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Done in High Priority Backlog Apr 11, 2021
@m2-community-project m2-community-project bot moved this from Done to Pull Request In Progress in High Priority Backlog Apr 11, 2021
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Ready for Development in High Priority Backlog Aug 24, 2021
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Ready for Development in High Priority Backlog Aug 24, 2021
@m2-community-project m2-community-project bot moved this from Ready for Development to Done in High Priority Backlog Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Customer Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done 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 Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Development

Successfully merging a pull request may close this issue.

8 participants