Refactor hookActionCustomerAccountAdd in ps_emailsubscription#121
Refactor hookActionCustomerAccountAdd in ps_emailsubscription#121Codencode wants to merge 3 commits intoPrestaShop:devfrom
Conversation
ps_emailsubscription.php
Outdated
| $this->sendVoucher($email, $code); | ||
| } | ||
|
|
||
| return (bool) Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'emailsubscription WHERE id_shop=' . (int) $id_shop . ' AND email=\'' . pSQL($email) . "'"); |
There was a problem hiding this comment.
| 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) . '"'); |
There was a problem hiding this comment.
Or only ' with slash ' ?
There was a problem hiding this comment.
@Touxten, I based it on the previous code, but if you think it's better this way, I'll make the change.
There was a problem hiding this comment.
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 !
There was a problem hiding this comment.
@Touxten I made the change you suggested, it does look better stylistically :-)
Thanks!
|
I'm going to do a PR to correct the tests. |
3756e51 to
b4ba7f6
Compare
|
@Touxten your PR worked perfectly! Thanks! |
|
ping @kpodemski |
paulnoelcholot
left a comment
There was a problem hiding this comment.
Hello @Codencode,
I tested your PR and I found some bug :
PR-2026-03-26_10.57.47.mp4
I have the problem when Double opt-in are activated or desactivated. And only for an account creation. I don't have this problem when I want to subscribe to the newsletter without creating an account.
Can you check that please?
Thanks!
|
@paulnoelcholot you were right, there really was an error in the DELETE (the space was missing between the id_shop filter and the email condition), so the query is now valid and the behavior works again. |
hookActionCustomerAccountAddlogic by acting only on valid emails and newsletter-subscribed customers, removing unnecessary and unreachable code.Related: #114 (comment)