From poll.module:

+++ modules/poll/poll.module 25 Jan 2010 21:34:11 -0000
@@ -720,7 +720,8 @@ function poll_vote($form, &$form_state)
-      'hostname' => $user->uid ? ip_address() : '',
+      'hostname' => $user->uid ? '' : ip_address(),

It doesn't make a lot of sense to only store the hostname for anonymous users. Some extra history in #602998-12: Poll vote missing timestamp and broken for anon users

Comments

grndlvl’s picture

StatusFileSize
new1.26 KB

Made change to store the hostname for all users for polls.

<?php
@@ -720,7 +720,7 @@ function poll_vote($form, &$form_state) 
       'nid' => $node->nid,
       'chid' => $choice,
       'uid' => $user->uid,
-      'hostname' => $user->uid ? '' : ip_address(),
+      'hostname' => ip_address(),
?>

Needed to change poll_load query for anon users so that it does not do the lookup completely based on the hostname but also user.uid = 0.

<?php
@@ -483,7 +483,7 @@ function poll_load($nodes) {
         $result = db_query('SELECT chid FROM {poll_vote} WHERE nid = :nid AND uid = :uid', array(':nid' => $node->nid, ':uid' => $user->uid))->fetchObject();
       }
       else {
-        $result = db_query("SELECT chid FROM {poll_vote} WHERE nid = :nid AND hostname = :hostname", array(':nid' => $node->nid, ':hostname' => ip_address()))->fetchObject();
+        $result = db_query("SELECT chid FROM {poll_vote} WHERE nid = :nid AND hostname = :hostname AND uid = 0", array(':nid' => $node->nid, ':hostname' => ip_address()))->fetchObject();
?>
grndlvl’s picture

Status: Active » Needs review
aaronbauman’s picture

StatusFileSize
new1.9 KB

Rerolled @ HEAD

It took me a second to figure out where hunk #1 failed, so I added some comments.

jhodgdon’s picture

Category: bug » feature
Status: Needs review » Reviewed & tested by the community

These changes look reasonable, the comments are helpful, and the patch is clean.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.