I get the following error message when I try to set a webform conditional.
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '20660-0' for key 'PRIMARY': INSERT INTO {webform_conditional} (nid, rgid, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 20660 [:db_insert_placeholder_1] => 0 [:db_insert_placeholder_2] => -1 ) in drupal_write_record() (line 7334 of /home/whistler/public_html/dev/includes/common.inc).
I have tried setting different fields as the conditional trigger but get the same effect. My webform was recently upgraded from 3.x branch to 4.12 so I thought that might be the problem but I completely uninstalled webform and removed all db tables and did re-install of the module and created a new form from scratch but still get the error when trying to set a conditional
This site was upgraded from drupal 6 to drupal 7 about 5 months ago.
Can anyone point to in the right direction for a resolution?
Comment | File | Size | Author |
---|---|---|---|
#18 | webform-conditionals_save-2690815-18.patch | 1.64 KB | DanChadwick |
#14 | webform-issues_when_import_conditionals-2690815-1-7.patch | 600 bytes | guilopes |
|
Comments
Comment #2
guilopes CreditAttribution: guilopes commentedSame issue here, the following patch should solve this issue
I had this issue when exported the webform by features and tried re import it
Comment #3
guilopes CreditAttribution: guilopes commentedComment #5
guilopes CreditAttribution: guilopes commentedComment #6
guilopes CreditAttribution: guilopes commentedComment #8
guilopes CreditAttribution: guilopes commentedComment #9
guilopes CreditAttribution: guilopes commentedComment #11
guilopes CreditAttribution: guilopes commentedComment #12
guilopes CreditAttribution: guilopes commentedComment #14
guilopes CreditAttribution: guilopes commentedComment #15
DanChadwick CreditAttribution: DanChadwick commentedIn debugging this, I see a bigger problem. The intention of this code to is allow the conditionals to be edited, but due to the way form values are converted into the webform conditionals, the conditionals array and individual conditionals will NEVER be identical when using the conditionals-definition page.
So we can push forward and make the form values into an actual conditional (without superfluous form_state values, such as button names and weights, and with the missing nid). Or we can retreat and simply delete and re-insert the conditionals when using the conditionals page.
Comment #16
DanChadwick CreditAttribution: DanChadwick commentedWorked on this a bit more. It turns out to be very hard to make the condtionals from the form exactly match the database to allow the array comparisons for delete/insert to work. There are missing fields which are supplied by the database (e.g. andor) and fields which are set during the process of the insert (the rule/action's nid/rgid/rid/aid).
I'm posting the code I used to remove the elements in the form_state that aren't in the schema, but it isn't sufficient:
I think the best course of action is to fix the delete/insert, understanding that for the case of editing the conditionals with the form, every conditional will be deleted and then inserted. The differential optimization code will probably work for features though.
Comment #18
DanChadwick CreditAttribution: DanChadwick commentedCommitted tweaked patch to 7.x-4.x. Thanks for your help everyone.
Comment #19
DanChadwick CreditAttribution: DanChadwick commentedComment #20
fenstratClosing to clear out the old Webform 8.x-4.x branch. See #2827845: [roadmap] YAML Form 8.x-1.x to Webform 8.x-5.x.
Comment #22
guilopes CreditAttribution: guilopes at Dexa commented