I've been seeing problems whereby if a user has rated content from within a comment via the fivestar_comment module, and then tries to edit the comment to remove the rating, it is not properly deleted.
What happens is that although the rating is removed from the comment, it remains in the main votingapi data structures and so is still included in things like the average rating.
Having looked through the code, it appears there are two problems:
1) At one point where fivestar_comment_delete() is called, it is being passed a user_id instead of a vote_id.
2) Vote IDs are not being stored in the fivestar_comment database table properly, and so even after fixing (1), the correct vote_id is still not used to try and delete the vote.
I've attached a patch that fixes both these issues (although it obviously won't fix any existing bad entries in the database).
For reference, I'm using fivestar-6.x-1.18 and votingapi-6.x-2.3.
Comment | File | Size | Author |
---|---|---|---|
#17 | fivestar_comment.module.601160.patch | 505 bytes | mr.j |
#15 | fivestar_comment.module.601160.patch | 510 bytes | mr.j |
fivestar.patch | 1.4 KB | penguin25 | |
Comments
Comment #1
lonelyrobot CreditAttribution: lonelyrobot commentedHave the same issue. Applied the patch. Works perfectly.
Comment #2
daneyuleb CreditAttribution: daneyuleb commentedWoot! Thanks for that--worked for me too! I really appreciate you tracking the problem down!
Comment #3
MatteNoob CreditAttribution: MatteNoob commentedThis was an amazing patch, thank you! You solved a problem I've been ripping my hair out to solve! You are my #1 hero! WOOOHOOO! :D
For refrence: I used the same versions as the "patchman" :)
Comment #4
sedmi CreditAttribution: sedmi commentedI have tried patch, and it works for deletion of registered user's vote. But if anonymous users are allowed to vote and their comment plus vote is deleted, average isn't updated, it still registers a vote.
Comment #5
AgentD CreditAttribution: AgentD commentedI'm having the same issue with 6x 1.19. Since it's a different version, I'm hesitant to apply the patch.
Can you tell me how to clear a vote from the database? I've already deleted the comment, but it's still showing in the average.
Thanks for any assistance!
Dan
Comment #6
Timur5 CreditAttribution: Timur5 commentedSame here, an anonymous user can vote on my website, and no matter whether the comment is approved or immediately deleted by admin without ever being approved, the vote stays and it is visible to all users.
Comment #7
ezra-g CreditAttribution: ezra-g commentedMarked #601160: Comment-cast ratings not deleted with comment, which has a commit already, as a dupe of this.
Comment #8
vkareh CreditAttribution: vkareh commentedThis patch works well for 6.x-1.19.
Also, #249547: Deleting a comment does not delete the attached vote. seems like a duplicate of this issue.
Comment #9
zazinteractive CreditAttribution: zazinteractive commentedWhat is the difference between the two patches
Comment #10
vkareh CreditAttribution: vkareh commentedBoth patches address the issue of inserting and updating the vote properly (which allows it to be deleted eventually), but the patch in this thread adds the proper
fivestar_comment_delete()
call, which actually deletes the commentComment #11
zazinteractive CreditAttribution: zazinteractive commentedThanks for the answer. Shouldn't the other issue be deleted completely then to avoid confusion?
Comment #12
vkareh CreditAttribution: vkareh commentedGood idea. Marked #249547: Deleting a comment does not delete the attached vote. as a duplicate of this.
Comment #13
SeanA CreditAttribution: SeanA commentedCorrecting comment #7: #349900: Comment-cast ratings not deleted when comment is deleted. was marked as a dupe of this.
Confirm that original patch by penguin25 fixes this bug. (EDIT- And that the other patches floating around do not provide a complete fix.)
Comment #14
penguin25 CreditAttribution: penguin25 commentedIt looks like the patch in #349900: Comment-cast ratings not deleted when comment is deleted. has been applied to the codebase instead of this patch (see http://drupalcode.org/project/fivestar.git/commit/fdd95d3e91b0fe571824ea...).
As such, the 6.x-1.20 release has an incomplete fix for this issue.
Comment #15
mr.j CreditAttribution: mr.j commented#14 is correct. This is still not fixed.
The patch to 6.x-1.20 is attached.
Comment #17
mr.j CreditAttribution: mr.j commentedLets try that again
Comment #19
whiteph CreditAttribution: whiteph commentedWe can no longer support the Drupal 6 version of Fivestar. It is in security maintenance mode only. When the Drupal 8 version of Fivestar is released, the Drupal 6 version will be officially deprecated.
Comment #20
mr.j CreditAttribution: mr.j commentedYou have had a simple one line patch sitting here on a plate for over 6 months and have failed to commit it. Why don't you commit the patches that you have been given and issue a final release so at least anyone else still using 6.x due to several modules without upgrade paths that prevent us from upgrading to 7.x can at least download something that isn't broken? There are still around 6000 sites using the 6.x version of this module, more than the are using the last release of 7.x.
Comment #21
whiteph CreditAttribution: whiteph commentedSee Help testing Drupal 6 patches.