If an anonymous voter tries to vote again or change their vote, it causes an error in the votingapi modules since it passes a value instead of an object, as votingapi_change_vote expects an object, not a value.

Need to change the db_result in or near line 270 to db_fetch_object

--if ($old_vote = db_result(db_query("SELECT vote_id FROM {votingapi_vote} WHERE content_type = 'node' AND content_id = %d AND value_type = '%s' AND tag = 'vote' AND uid = %d AND hostname = '%s' AND timestamp > %d", $nid, $vote->value_type, $uid, $hostname, time() - (60 * 60 * 24)))){ // existing votes from the same IP address within the past day

to

--if ($old_vote = db_fetch_object(db_query("SELECT vote_id FROM {votingapi_vote} WHERE content_type = 'node' AND content_id = %d AND value_type = '%s' AND tag = 'vote' AND uid = %d AND hostname = '%s' AND timestamp > %d", $nid, $vote->value_type, $uid, $hostname, time() - (60 * 60 * 24)))){ // existing votes from the same IP address within the past day

--Greg

CommentFileSizeAuthor
#2 jrating_anonymous_voting.patch1.11 KBGman

Comments

melon’s picture

It works great. Please provide patch and let's hope the best the maintainer approves it.

Gman’s picture

StatusFileSize
new1.11 KB

Here is the patch. Please review, though it should be ready for committing now.

-Greg

hickory’s picture

Status: Active » Fixed

Committed, thanks for the patch.

Anonymous’s picture

Status: Fixed » Closed (fixed)