When running a ranking poll with randomised options, the option number saved into the database does not match the vote_offset of the option the user ranked. This is because the ranking form uses the array index to uniquely identify each option and *not* the vote_offset, like it should.
If all users choose to rank the choice listed at the top of the form as their 1st, the winning choice is always the item from {decisions_choices} with vote_offset 1, regardless of where that item was in the list.
Attached patch fixes the issue.
Unfortunately, because the order of items is randomised, there is no way to find out actual results of polls that were run with this bug in place.
Please do not apply this patch without also fixing #1590244: "Randomize answers order" doesn't work on PHP >= 5.2.10.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | not-so-random-1589306-2.patch | 5.21 KB | cafuego |
| randomise-choice-fix.patch | 475 bytes | cafuego |
Comments
Comment #0.0
cafuego commentedUpdated issue summary.
Comment #1
cafuego commentedAttached patch resolves this issue for both ranking and select votes. Additionally, it resolves issue #1590244: "Randomize answers order" doesn't work on PHP >= 5.2.10, so randomising options works properly on PHP >= 5.2.10.
Comment #2
webchickCan confirm that this fixed randomization under PHP 5.3, and it is recording the proper vote on a ranking poll.
I don't really feel qualified to mark RTBC due to unfamiliarity with the rest of the code, but since this fixes a HUGE bug, I'm going to be bold.
Comment #3
anarcat commentedfix committed, thanks, sorry for the delays.
Comment #4.0
(not verified) commentedAdd reference to randomise helper booboo.