Comments

FuN_ViT’s picture

sorry - a little bug in 216 line in poll.module

replace with what:

    '#default_value' => isset($node->ip_filter_time)?$node->ip_filter_time:$_ip_filter_time[2],

and update bug (serious)
line 661:
replace to

db_query('UPDATE {poll} SET runtime = %d, active = %d, ip_filter_time=%d WHERE nid = %d', $node->runtime, $node->active, $node->ip_filter_time,$node->nid );
drumm’s picture

Version: 5.7 » 7.x-dev
Category: task » feature
Priority: Critical » Normal
Status: Patch (to be ported) » Active

Please attach a patch file, see http://drupal.org/patch/create

The brief description makes this look like a feature request, but I could be wrong since not much is explained. Either way, changes this big must happen in the development version first.

hillaryneaf’s picture

The poll is not showing up for me for anonymous users... does anyone else have this problem.. or know what may be causing it?

Susurrus’s picture

#14179: Optional cookie based voting authentication is related, though I'm not sure which should be labeled a duplicate of which...

pash7ka’s picture

StatusFileSize
new3.86 KB

I've patched poll.module from Drupal 6.12 to support cookies if they are enabled and revert to IP if they aren't.

greg.harvey’s picture

Status: Active » Needs review

This will live in limbo forever if you don't set it to "needs review". =P

Ps - sorry, reading the note it's a D6 patch in a D7 issue, but it could still be reviewed and probably used.

Status: Needs review » Needs work

The last submitted patch failed testing.

greg.harvey’s picture

Assigned: Unassigned » greg.harvey

Ahh, Simple Test. I'll get this working for D6 next week and then do a D7 port of the patch for review/re-test. Promise. =)

greg.harvey’s picture

Status: Needs work » Needs review
StatusFileSize
new4.68 KB

Ok, D7 patch attached. Aside from general tidy-up and doing things the D7 way, added a few lines to poll_cancel() to get rid of the cookie if the user cancels their vote.

Works for me! Other testers (+ bot) encouraged. =)

greg.harvey’s picture

Ps - anyone looking for the Drupal 6 patch, tidied version has been moved here: #14179: Optional cookie based voting authentication

Status: Needs review » Needs work

The last submitted patch failed testing.

greg.harvey’s picture

Status: Needs work » Needs review
StatusFileSize
new4.8 KB

Hmm, I think the fail there is because of the way Subclipse produced the patch. Trying again.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Excellent. Code looks good. I'm pretty sure that our simpletest browser persist cookies so it would be great to write a test for this. Perhaps the test can wait come after slush deadline. Lets ask the committers via this RTBC. Feel free to work on the test today though.

In other news, perhaps someone here cares to fix a major poll bug - #39432: Disallow anonymous voting when page caching is turned on

dries’s picture

Status: Reviewed & tested by the community » Needs work

This isn't quite ready yet, however, most of the things are minor.

+++ modules/poll/poll.module
@@ -447,7 +448,18 @@ function poll_load($nodes) {
+        if (isset($_COOKIE["poll-".$node->nid])) {
+          $iprnd = $_COOKIE["poll-".$node->nid];

Code style issue: (1) incorrect spacing and (2) wrong abbreviation of variable.

+++ modules/poll/poll.module
@@ -447,7 +448,18 @@ function poll_load($nodes) {
+          if (!preg_match("/^[0-9.\\-]+$/", $iprnd)) {

Please add some phpDoc.

+++ modules/poll/poll.module
@@ -679,14 +695,46 @@ function poll_vote($form, &$form_state) 
+      db_insert('poll_vote')

Can't the insert code be simplified through db_merge()?

+++ modules/poll/poll.module
@@ -679,14 +695,46 @@ function poll_vote($form, &$form_state) 
+    // Anonymous, no cookies, use IP address

Misses trailing dot.

+++ modules/poll/poll.module
@@ -873,6 +921,11 @@ function poll_cancel($form, &$form_state
+  // Vote canceled, delete any poll cookies
+  if (isset($_COOKIE["poll-".$node->nid])) {
+    setcookie("poll-".$node->nid, "", time() - 3600, "/");
+  }

Incorrect spacing.

greg.harvey’s picture

StatusFileSize
new4.92 KB

Attached patch is mostly done. I need to look in to db_merge() - it's new and I'm not familiar.

greg.harvey’s picture

Status: Needs work » Needs review

Hmm, the inserts aren't inserts on different tables. They're different inserts on the same table, depending on the circumstances. I just read around db_merge() briefly and I don't think it's appropriate here, but I'm the first to admit I'm not familiar with this approach, so if someone who is says otherwise, please make it so.

Otherwise, I've cleaned up all the formatting stuff, hopefully to your satisfaction. =)

Status: Needs review » Needs work

The last submitted patch failed testing.

greg.harvey’s picture

Status: Needs work » Needs review
StatusFileSize
new5 KB

I'll try that again, without being so lazy! =P

On a side point, joachim pointed out in IRC that, when this patch is ready, Poll should use the fruits of this issue too: #440876: Reuse comment.module's anonymous cookie information

greg.harvey’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work

Since this didn't make the cut this time, it needs re-rolling as a D8 patch. Updated as appropriate.

sowmithrii’s picture

Status: Needs work » Needs review
greg.harvey’s picture

Why have you re-queued #12 when #18 is the latest patch? And anyway, this is a feature and features are frozen for D7, so even re-rolling it against dev is a waste of time, since it simply will not be committed. We need to sit tight until someone either says D7 is taking feature requests again (post-launch) or D8 development is properly under way.

greg.harvey’s picture

Status: Needs review » Needs work

Setting to needs work - D7 patch will need porting for D8 (eventually).

mrkschan’s picture

StatusFileSize
new4.25 KB

Hi there,

I'm uploading a .diff file that I modified the patch at comment #18. This .diff applies to Drupal 7.4 copy so that cookie based polling is enabled.

oscarino’s picture

Hi Greg Harvey,

I tried to use your D7 patch but the codes are not the same anymore. I believe you did it for Drupal while it was still on Dev and now it's up to Drupal 7.15...

Is it possible if you update it to match the latest Drupal 7 version?

Thank you ahead of time ;)

oscarino’s picture

Actually - mrkschan patch also works for Drupal 7.15 although the are many more extra lines of codes so you need to play a bit and understand where exactly his new lines of codes need to fall. The way I did it was to download drupal 7.4 and follow the patch using the lines provided in the patch

alexpott’s picture

Project: Drupal core » Poll
Version: 8.x-dev » 8.x-1.x-dev
Component: poll.module » Code

Poll has been removed from core

adammalone’s picture

Assigned: greg.harvey » Unassigned

This will need a reroll to work with poll outside core and potentially to tie in nicely with Poll's session handling.

berdir’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

This hasn't been updated in 5 years. While there are possibly improvements, anonymous voting is working fairly well. Closing this.