Skip to content

Refactor hookActionCustomerAccountAdd in ps_emailsubscription#121

Open
Codencode wants to merge 2 commits intoPrestaShop:devfrom
Codencode:refactor/email-subscription-cleanup-hook
Open

Refactor hookActionCustomerAccountAdd in ps_emailsubscription#121
Codencode wants to merge 2 commits intoPrestaShop:devfrom
Codencode:refactor/email-subscription-cleanup-hook

Conversation

@Codencode
Copy link
Contributor

@Codencode Codencode commented Dec 7, 2025

Questions Answers
Description? This PR simplifies the hookActionCustomerAccountAdd logic by acting only on valid emails and newsletter-subscribed customers, removing unnecessary and unreachable code.

Related: #114 (comment)
Type? refacto
BC breaks? no
Deprecations? no
Fixed ticket?
How to test?

Touxten
Touxten previously approved these changes Jan 21, 2026
$this->sendVoucher($email, $code);
}

return (bool) Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'emailsubscription WHERE id_shop=' . (int) $id_shop . ' AND email=\'' . pSQL($email) . "'");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return (bool) Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'emailsubscription WHERE id_shop=' . (int) $id_shop . ' AND email=\'' . pSQL($email) . "'");
return Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'emailsubscription` WHERE id_shop = ' . (int) $id_shop . 'AND email = "' . pSQL($email) . '"');

Copy link
Contributor

@Touxten Touxten Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or only ' with slash ' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Touxten, I based it on the previous code, but if you think it's better this way, I'll make the change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I saw that. What's causing me trouble is the mix of ' / ” at the end of the query.

I've validated the PR. I'll leave it up to you to choose :D Nice job !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Touxten I made the change you suggested, it does look better stylistically :-)
Thanks!

@Codencode Codencode requested a review from a team February 27, 2026 20:14
@Touxten Touxten closed this Feb 28, 2026
@github-project-automation github-project-automation bot moved this from Ready for review to Closed in PR Dashboard Feb 28, 2026
@Touxten Touxten reopened this Feb 28, 2026
@ps-jarvis ps-jarvis moved this from Closed to Ready for review in PR Dashboard Feb 28, 2026
@github-project-automation github-project-automation bot moved this from Ready for review to Reopened in PR Dashboard Feb 28, 2026
@Touxten
Copy link
Contributor

Touxten commented Feb 28, 2026

I'm going to do a PR to correct the tests.

@Touxten
Copy link
Contributor

Touxten commented Feb 28, 2026

#123

@Codencode Codencode force-pushed the refactor/email-subscription-cleanup-hook branch from 3756e51 to b4ba7f6 Compare March 2, 2026 14:23
@Codencode
Copy link
Contributor Author

@Touxten your PR worked perfectly!

Thanks!

@Codencode
Copy link
Contributor Author

ping @kpodemski

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reopened

Development

Successfully merging this pull request may close these issues.

2 participants