| Project: | Simple Review |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
Repro steps:
Create a review for a node, but don't give it a rating. Save it.
Go to the review and click 'Edit'. (You are either admin or have fixed the bug that stops you from editing your own reviews)
Select a rating. Save it.
Expected: Your review has a rating.
What actually happens: Your review still has not ratings. The rating for the node however displays 1 rating. Repeating the process doesn't add a rating to the review, but increases the number of ratings for the node.
What is happening: Since the first review was created without a rating the first time round, there was no entry in table {simple_review}. Subsequent updates to the rating don't insert an entry into {simple_review}, because it's assumed there is already one.
Solution:
in "function simple_review_comment" replace
<?php
if ($op == 'insert' && $vote) {
db_query("INSERT INTO {simple_review} (vid, cid) VALUES (%d, %d)", $vote->vote_id, $comment['cid']);
}
else if (!$vote) {
simple_review_delete_vote($comment['cid']);
}
?>with
<?php
if ($vote) {
if($op == 'update') {
db_query("DELETE FROM {simple_review} WHERE cid = %d", $comment['cid']);
}
db_query("INSERT INTO {simple_review} (vid, cid) VALUES (%d, %d)", $vote->vote_id, $comment['cid']);
}
else {
simple_review_delete_vote($comment['cid']);
}
?>Apologies for this not being a real patch. (I'm still a newbie)