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).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hussainweb’s picture

Status: Active » Needs review
FileSize
533 bytes

Attaching the patch as promised.

hefox’s picture

rules, etc. is not reloading the $node object before calling node_save again? That sounds like a bug in that workflow

mgifford’s picture

Is this also an issue in D8? If so, it would need to be fixed there first.

mgifford’s picture

Status: Needs review » Postponed (maintainer needs more info)

Right, 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.