Prerequisites
Describe the bug and add attachments
In ps_emailsubscription 2.8.3, an existing newsletter subscription stored in the emailsubscription table is removed when the related Customer object is updated, even if the customer did not unsubscribe or change the newsletter preference.
This seems inconsistent with the behavior introduced in #114, where an existing newsletter subscription is preserved when a subscriber later creates a customer account without checking the newsletter checkbox.
After account creation, the following state can therefore legitimately exist:
customer.newsletter = 0
emailsubscription.active = 1
However, on a later customer update, hookActionObjectCustomerUpdateBefore() deletes the entry from emailsubscription:
$customer = new Customer($params['object']->id);
$this->_origin_newsletter = (int) $customer->newsletter;
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'emailsubscription WHERE id_shop=' . (int) $params['object']->id_shop . ' AND email=\'' . pSQL($params['object']->email) . "'");
_origin_newsletter only stores the previous value of customer.newsletter. It does not take into account an active subscription stored in emailsubscription.
As a result, an unrelated customer profile update can remove the customer's existing newsletter subscription.
Steps to reproduce
Subscribe to the newsletter using an email address that does not yet have a customer account.
Create a customer account using the same email address, without selecting the newsletter checkbox.
Update the customer profile, for example: from the customer account/profile edit page, or during checkout, if the customer data is updated there.
Check the emailsubscription table.
Expected behavior
Updating customer profile data should not remove an existing newsletter subscription.
The subscription should remain active until the customer explicitly unsubscribes or the subscription is intentionally transferred to customer.newsletter.
Actual Result
The existing newsletter subscription stored in emailsubscription is removed after the Customer object is updated.
As a result, the customer is no longer considered subscribed even though they did not unsubscribe or change their newsletter preference.
PrestaShop version where the bug happens
1.7 - 9.1
Module version where the bug happens
2.8.3 - latest
PHP version(s) where the bug happened
No response
Your company or customer's name goes here (if applicable).
GetResponse
Prerequisites
Describe the bug and add attachments
In ps_emailsubscription 2.8.3, an existing newsletter subscription stored in the emailsubscription table is removed when the related Customer object is updated, even if the customer did not unsubscribe or change the newsletter preference.
This seems inconsistent with the behavior introduced in #114, where an existing newsletter subscription is preserved when a subscriber later creates a customer account without checking the newsletter checkbox.
After account creation, the following state can therefore legitimately exist:
However, on a later customer update, hookActionObjectCustomerUpdateBefore() deletes the entry from emailsubscription:
_origin_newsletter only stores the previous value of customer.newsletter. It does not take into account an active subscription stored in emailsubscription.
As a result, an unrelated customer profile update can remove the customer's existing newsletter subscription.
Steps to reproduce
Subscribe to the newsletter using an email address that does not yet have a customer account.
Create a customer account using the same email address, without selecting the newsletter checkbox.
Update the customer profile, for example: from the customer account/profile edit page, or during checkout, if the customer data is updated there.
Check the emailsubscription table.
Expected behavior
Updating customer profile data should not remove an existing newsletter subscription.
The subscription should remain active until the customer explicitly unsubscribes or the subscription is intentionally transferred to customer.newsletter.
Actual Result
The existing newsletter subscription stored in emailsubscription is removed after the Customer object is updated.
As a result, the customer is no longer considered subscribed even though they did not unsubscribe or change their newsletter preference.
PrestaShop version where the bug happens
1.7 - 9.1
Module version where the bug happens
2.8.3 - latest
PHP version(s) where the bug happened
No response
Your company or customer's name goes here (if applicable).
GetResponse