There's a corner case that can happen (i had a ticket open for this being caused for a different reason that was fixed a different way) when webform will create duplicate conditionals when there's any rules that act on a webform node after it's updated.

It seems that using drupal_write_record() to save / update the entry can cause a duplicate primary key error in this case.

It was suggested trying to use db_merge() in this case instead.

Comments

jannis created an issue. See original summary.

jannis’s picture

Here is a patch that will replace all drupal_write_record() calls with db_merge() instead. This allows me to add conditionals to webforms that rules act on after it is changed.

jannis’s picture

Status: Active » Needs review
jannis’s picture

ignore patch #2 wrong file, patch #4 is right

jannis’s picture

removed some debug code in #5

jannis’s picture

having a bit of trouble with patches today, this is #6 without any unecessary code

The last submitted patch, 4: webform-use-db_merge-for-adding-updating-conditionals-3045285-04.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

The last submitted patch, 5: webform-use-db_merge-for-adding-updating-conditionals-3045285-05.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work
jannis’s picture

simpletest threw some errors, updating the patch

jannis’s picture

jannis’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: webform-use-db_merge-for-adding-updating-conditionals-3045285-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

amit.drupal’s picture

Update Patch #11

amit.drupal’s picture

Status: Needs work » Needs review
jannis’s picture

just checked patch #14 -- applies cleanly and is doing the job

RTBC +1

jannis’s picture

Status: Needs review » Reviewed & tested by the community
liam morland’s picture

Is there a reason this isn't done with fields($rule) and fields($action)?

liam morland’s picture

Version: 7.x-4.19 » 7.x-4.x-dev
Status: Reviewed & tested by the community » Needs work

This needs a test.

What are the steps to reproduce the problem?

liam morland’s picture

Status: Needs work » Closed (outdated)

Drupal 7 is no longer supported. If this applies to a supported version, please re-open.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.