Closed (fixed)
Project:
Advanced Poll
Version:
5.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
16 Aug 2007 at 19:21 UTC
Updated:
29 Dec 2007 at 21:33 UTC
Jump to comment: Most recent file
In "advpoll_tab_votes" it appears you wanted to have 20 rows of votes per page. You are actually gettin 20 votes in the query. For a ranking poll with multiple votes per user, this cause a short list that can be cut off mid-vote.
This patch helps. Although I don't think it's perfect, it is much closer to what I think you intended. If "max choices" is set, then it uses that number of votes per row, otherwise it uses the number of choices.
I didn't go back and start with a fresh copy of the module, so the line numbers correspond to having my "view results" patch applied. You should be able to see how to do this anyway. It's a very simple patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | advpoll_view_votes.patch | 3.72 KB | ChrisKennedy |
| #17 | advpoll_view_votes.patch | 3.73 KB | ChrisKennedy |
| #15 | advpoll_view_votes.patch | 2.5 KB | ChrisKennedy |
| #7 | advpoll_view_votes.patch | 1.66 KB | ChrisKennedy |
| advpoll_tabfix.txt | 1.27 KB | nancydru |
Comments
Comment #1
ChrisKennedy commentedThanks for the bug report and patch. You're right that the incorrect number of votes are being displayed and that this is a bit better, although it will display too many votes if anyone did not submit a complete ranking and therefore the list can still be cut off mid-vote.
Taking a quick look, it seems like what we really need is a unique ID per vote that we can aggregate by - we should probably try to get this added to VotingAPI. Another option would be to include a timestamp with each vote, although this would be slightly unreliable on high-traffic sites with multiple anonymous votes from the same IP (at the same second).
Comment #2
nancydruComment #3
ChrisKennedy commentedThis still needs to be fixed. And I noticed a few weeks back that Voting API already sets a unique id per vote, so this won't be too hard to implement.
Comment #4
nancydruIt may be a while before I can work on it.
Comment #5
ChrisKennedy commentedBump - I'm going to do this sometime in the next week. It'll make it easy to add a delete vote link for each row too.
Comment #6
ChrisKennedy commentedStill need to fix this.
Comment #7
ChrisKennedy commentedOkay here is a patch.
Comment #8
ChrisKennedy commentedBtw, here is one possible testing procedure: create a poll.module poll with 3 choices and pre-populate each choice with 6 votes (18 in total), convert it to an Advanced Poll, change the choice limit back to 0, then vote on all the available choices (so that there 19 voters but 21 voted on choices). With this patch the votes tab should only show one page, but without the page the votes will run over to two pages.
Comment #9
anders.fajerson commentedFollowing those steps, only two choices are listed for the advpoll voter.
Comment #10
ChrisKennedy commentedUgh, I could have sworn there was one vote_id per vote... but apparently I am crazy. Maybe this issue will motivate me to drop VotingAPI and just reimpliment the few features that we specifically use.
Comment #11
nancydruWell, sort of. It looks like there is a vote_id that is unique, but does not represent a single vote. You have to get all the votes for the "content_id" and "UID"- that's a single vote, I think.
Comment #12
ChrisKennedy commentedNo, the content_id is the node id. There isn't anything that signifies a vote by a user - you have to just get all the rows for a uid-hostname-timestamp combination. Not fun.
Comment #13
anders.fajerson commentedFor non-anonymous users, isn't content_type + content_id + uid a single vote by a user in our case? It's anonymous users that's the special case here, right?
Comment #14
ChrisKennedy commentedRight
Comment #15
ChrisKennedy commentedHere is a revised patch that actually works for the test procedure I proposed, imagine that.
Comment #16
anders.fajerson commentedIndeed, the testcase works.
Errors are generated if a poll doesn't have a vote.
That last chunk of code is slightly scary. Feel free to expand that code comment about security a little bit, e.g. what we are trying to protect ourselves from.
So basically what you are doing here is to check by id for logged in users and by timestamp + hostname for anonymous (?). Also feel free to elaborate on what is missing in VotingAPI to deal with this more cleanly (just an extra column for an id per vote?). How serious are you about ditching VotingAPI, is it something that should be considered for 6.x? (sorry for getting slightly off topic).
Great work as always Chris!
Comment #17
ChrisKennedy commentedThanks for the solid review.
Fixed the no-votes error - sorry, should have caught that myself.
Added clearer code comments; this will definitely be handy when reviewing the code in the future. I found out how to use placeholders for array data at http://drupal.org/writing-secure-code#comment-185423 (kind of hard to find).
Yep, VotingAPI just needs another column that is a unique id for the set of rankings a user submits as their vote. The current conception assumes that a vote consists of only a single value, rather than potentially a group of values. I'm not too set on ditching VotingAPI, it's just frustrating at times. Maybe I'll restart submitting patches to it so I can fix its problems myself.
Comment #18
anders.fajerson commentedThose code comments are great!
The check doesn't work though. How about using
if (count($uids) > 0)instead and remove$votes = array();which doesn't seem to be used. I'd roll a new patch but think there might be another issue:Tried my old nemesis ranking poll and all I get is "=" as seperator. Looked at the code but couldn't figure it out...
Comment #19
ChrisKennedy commentedUgh buggy mc. bugster. Should be fixed.
Comment #20
anders.fajerson commentedNice.
Comment #21
ChrisKennedy commentedCommitted: http://drupal.org/cvs?commit=91491
Comment #22
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.