Prevent attribute deletion from wiping all wishlists and statistics - #474
Open
boo-code wants to merge 1 commit into
Open
Prevent attribute deletion from wiping all wishlists and statistics#474boo-code wants to merge 1 commit into
boo-code wants to merge 1 commit into
Conversation
|
Hello @boo-code! This is your first pull request on blockwishlist repository of the PrestaShop project. Thank you, and welcome to this Open Source community! |
2 tasks
removeNonExistingProductAttributesFrom{Wishlist,Statistics}() selected every
row whose id_product_attribute had no matching product_attribute. Simple
products use id_product_attribute = 0, which never matches, so those rows were
selected and removeProductFrom{Wishlist,Statistics}(null, 0) was called. With a
null product and a falsy 0 attribute, the WHERE clause built there is empty, so
Db::delete() ran 'DELETE FROM ps_wishlist_product' (and the statistics table)
with no condition, wiping every customer's wishlist on any attribute deletion.
Restrict the orphan lookups to real combinations (id_product_attribute > 0), and
guard the delete helpers so an empty WHERE clause can never delete the table.
boo-code
force-pushed
the
fix/attribute-delete-wipes-wishlists
branch
from
July 29, 2026 01:41
55fb499 to
19838e1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ps_wishlist_productandps_blockwishlist_statisticstables (every customer's wishlist + all statistics).hookActionAttributeDeletecallsremoveNonExistingProductAttributesFrom{Wishlist,Statistics}(), whoseLEFT JOIN product_attribute ... WHERE pa.id_product_attribute IS NULLlookup also matched simple-product rows (which useid_product_attribute = 0, never present inproduct_attribute). Each match calledremoveProductFrom…(null, 0); with anullproduct and a falsy0attribute the helper built an empty WHERE clause, soDb::delete()executedDELETE FROM ps_wishlist_product(and the statistics table) unconstrained. Fix = (1) restrict the orphan lookups to real combinations (id_product_attribute > 0), and (2) guard the delete helpers so an empty WHERE clause can never run a table-wide DELETE.ps_wishlist_productthree rows withid_product_attribute=0(simple), a valid combination id, and a non-existent id (e.g.999999); callWishList::removeNonExistingProductAttributesFromWishlist(). Before: table emptied (3 → 0). After:0and the valid combination survive, only999999is removed; andWishList::removeProductFromWishlist(null, 0)returnsfalsewithout deleting anything.