Cookie type does not work on my installation. Voting in a poll and then refreshing the page allows the user to vote again.

In advpoll_add_votes we have the following line;

setrawcookie($vote['type'] . $vote['nid'], 'vote', time() + (60 * $vote['duration']), '/', $cookie_domain);

The problem is that $vote['type'] is 'node' whereas in the test in advpoll_user_eligibility we have this if statement;

if ($data->mode === 'cookie' && isset($_COOKIE[$node->type . $node->nid])) {

And $node->type is 'advpoll'.

Heres my cookie;

  'node53150' => string 'vote' (length=4)

And here's $node->type . $node->nid

string 'advpoll53150' (length=12)
CommentFileSizeAuthor
#2 2491913-failed-cookie-matching.diff1.47 KBcb

Comments

cb’s picture

Project: Voting API » Advanced Poll
Version: 7.x-2.12 » 7.x-3.x-dev
cb’s picture

Status: Active » Needs review
StatusFileSize
new1.47 KB

Patch attached.

I created a new key in $vote because I could see $vote['type'] being used elsewhere.

tripper54’s picture

Thanks for spotting. This is no doubt a hangover from a confusion between bundles and types when the D7 version of the module was first built.

I'll have a close look & test over the weekend.

tripper54’s picture

Status: Needs review » Fixed

Committed, thanks.

  • tripper54 committed 2c2a8d9 on 7.x-3.x authored by cbiggins
    Issue #2491913 by cbiggins: Cookie tests against mismatched key
    

Status: Fixed » Closed (fixed)

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