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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lonelyrobot’s picture

Status: Active » Reviewed & tested by the community

Have the same issue. Applied the patch. Works perfectly.

daneyuleb’s picture

Woot! Thanks for that--worked for me too! I really appreciate you tracking the problem down!

MatteNoob’s picture

This 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" :)

sedmi’s picture

Status: Reviewed & tested by the community » Needs work

I 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.

AgentD’s picture

I'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

Timur5’s picture

Same 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.

ezra-g’s picture

Title: Problems with deleting ratings in fivestar_comment » Comment-cast ratings not deleted with comment

Marked #601160: Comment-cast ratings not deleted with comment, which has a commit already, as a dupe of this.

vkareh’s picture

Version: 6.x-1.18 » 6.x-1.19
Status: Needs work » Reviewed & tested by the community

This 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.

zazinteractive’s picture

What is the difference between the two patches

vkareh’s picture

Both 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 comment

zazinteractive’s picture

Thanks for the answer. Shouldn't the other issue be deleted completely then to avoid confusion?

vkareh’s picture

Good idea. Marked #249547: Deleting a comment does not delete the attached vote. as a duplicate of this.

SeanA’s picture

Correcting 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.)

penguin25’s picture

It 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.

mr.j’s picture

Version: 6.x-1.19 » 6.x-1.20
FileSize
510 bytes

#14 is correct. This is still not fixed.
The patch to 6.x-1.20 is attached.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, fivestar_comment.module.601160.patch, failed testing.

mr.j’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
505 bytes

Lets try that again

Status: Reviewed & tested by the community » Needs work

The last submitted patch, fivestar_comment.module.601160.patch, failed testing.

whiteph’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)

We 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.

mr.j’s picture

You 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.

whiteph’s picture