Problem/Motivation
Under certain cases, saving a new poll can cause the choices to be duplicated. This can commonly happen with rules but in theory, it can happen when any module saves the poll node in hook_node_insert
.
The issue, steps to reproduce the bug using rules is described in #1826038: Poll choice duplicates when using rules to publish.
Proposed resolution
On digging deep, I found the problem in poll_update
. This function calls db_merge
with chid as key, which is not set yet.
In my opinion, this is the proper place for the fix. It is not really a rules problem as it could theoretically occur in other situations too. The poll module should track the choice id's and use that when trying an update.
I am attaching a patch with the fix in the comment (so that I can get the issue number).
Comment | File | Size | Author |
---|---|---|---|
#1 | drupal-poll-choice-duplicate-2245851-1.patch | 533 bytes | hussainweb |
Comments
Comment #1
hussainwebAttaching the patch as promised.
Comment #2
hefox CreditAttribution: hefox commentedrules, etc. is not reloading the $node object before calling node_save again? That sounds like a bug in that workflow
Comment #3
mgiffordIs this also an issue in D8? If so, it would need to be fixed there first.
Comment #4
mgiffordRight, Poll module got nixed in D8, so that's fine to fix it here.
@hefox was asking for clarifications on the workflow so changing the status to Postponed.