Editing a poll with votes creates inconsistent state

Steps to reproduce

  • Create a new poll
  • Vote for an option
  • Edit the poll and add another option

Expected result
The poll should show the additional option and the already cast votes should be visible.

Actual result
The additional option is visible and the votes are still there, but the total_votes are gone which results in invalid results.
I voted for “Yes” in the following example and then added the “I don’t know” option to it.

  • Yes
  • No
  • Maybe
  • I don’t know

0 voters


Bonus bug
Same steps as above with the following additional steps:

  • Click “Hide results” when the poll is already “destroyed”.
  • Vote for another option like “No”.

See the following example for the result of those actions:

  • Yes
  • No
  • Maybe
  • I don’t know

0 voters

7 إعجابات

@gerhard I can reproduce this bug. I’ll fix it and propose pull request.

إعجابَين (2)

Just pushed a fix that properly reset all votes when the number of options changes since there’s no easy way of “merging” options when they might be added/removed/sorted.

This shouldn’t be too much of a problem since this is only allowed for the first 5 minutes.

https://github.com/discourse/discourse/commit/033761d2f629f45d8409ce7c5a547ff30ebb3543

إعجابَين (2)

@zogstrip yep. You are right. I cant find easy way to merge old votes. Instead of storing poll’s data in html, we can use redis for store poll. What about this feature?

Not sure what you mean by that.