Skip to content

Incorrect caching subscription status in newsletter plugin  #19345

Closed
@wojtekn

Description

@wojtekn

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

Metadata

Metadata

Labels

Component: CustomerFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions