I have a webform with webform pager, and trying to export from that site to another. Upon completing the import, the components are all out of order, and reordering is very difficult. Some don't come in, and that appears to be an inconsistent from one import to the next. I tried to preface each one's label with a number so I could manually reorder, but it's very cumbersome.. The source is running Drupal Commerce Kickstart. I've tried importing to another site with D-Commerce kickstart, as well as one without. Both give the same issue, so I don't believe that is the issue.
I believe this issue renders the module unusable so this is a critical issue. It's a very important tool, and I am sure many users would like to use this module once it's fixed.
Update
Updated by: Cravecode on 2014-12-17, see comment #16 for details.
- Parent cid (aka: pid) isn't tracked and can't be matched up while importing. This leaves child components missing after the import is complete.
- Not getting the correct "next" cid. Causing "PDOException: Integrity constraint violation".
Comment | File | Size | Author |
---|---|---|---|
#25 | interdiff.txt | 2.06 KB | Angry Dan |
#25 | imported_form-1956622-25.patch | 2.51 KB | Angry Dan |
#19 | imported_form-1956622-19.patch | 2.84 KB | cravecode |
#3 | webform_share-component-order-1956622-3.patch | 4.33 KB | polynya |
#1 | webform_share-component-order-1956622-1.patch | 531 bytes | polynya |
Comments
Comment #1
polynya CreditAttribution: polynya commentedThis patch fixes the component order by using the component id (cid) from the import file. This ensures that components with a parent id (pid) are linked to the correct parent.
It works for an import into an empty webform but not if there is an existing component with the same cid. In that case we need the work proposed here: https://drupal.org/node/1289958#comment-6332384
Comment #2
Hiller CreditAttribution: Hiller commentedIt doesn't fix a problem with component relations. So i just removed both checkboxes from import form and rewrite import code to
for those who wants to use Only components... and Keep existing... settings to work should fix this to smth like
This should keep your existing components intact and will process your relations (pid->cid) to set new values. Though i do not test this as i don not need this. THIS IS JUST MY SUGGESTION SO BE CAREFULL
Comment #3
polynya CreditAttribution: polynya commentedThat's great, it works for me. I've created a new patch from your code. Thanks.
Comment #4
tripper54 CreditAttribution: tripper54 commentedchanged status
Comment #5
Alan D. CreditAttribution: Alan D. commentedI don't think we can delete and recreate sadly.
Comment #6
Hiller CreditAttribution: Hiller commentedFirst line will delete all webform components from db
second will remove webform instance from node and this will allow us to create new webform instance. so this is just an emulation of node_delete and node_insert
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedI applied this patch but still have a few issues:
1) If I check to NOT leave the current components, I get an error re: a key_restraint
2) All components are still not getting imported. I believe it is when there is a fieldset used, but I am still testing.
Comment #8
Hiller CreditAttribution: Hiller commentedMy code wasn't supposed to work. i do not need these options so i do not fix 'em and just suggest for other coders
Import with all options disabled works like a charm with any component and relations
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedI will try again, but I DID do the import with all unchecked and it did not import all components when there were fieldsets with sub components. I'll add more info later after I have a chance to research more.
Comment #10
FatherShawnI also have a fieldset that fails to import properly.
If I leave the default webform field empty in the content type and simply try to import into another node, nothing happens if both option boxes are unchecked. If either or both option boxes are checked I get:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '10-1' for key 'PRIMARY': INSERT INTO {webform_component} (nid, cid, pid, form_key, name, type, value, extra, required, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 10 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => staff_contact [:db_insert_placeholder_4] => Staff Contact [:db_insert_placeholder_5] => hidden [:db_insert_placeholder_6] => [node:author:mail] [:db_insert_placeholder_7] => a:2:{s:7:"private";i:0;s:11:"hidden_type";s:5:"value";} [:db_insert_placeholder_8] => 0 [:db_insert_placeholder_9] => 0 ) in webform_component_insert() (line 760 of /Users/shawn/Sites/edli/sites/all/modules/contrib/webform/includes/webform.components.inc).
If I paste the import code into the webform default components field in the content type settings, then on content creation I get a webform that contains all the components but the fields are not assigned to the fieldset - the fieldset is empty and the fields are siblings to the fieldset.
Comment #11
FatherShawnThe patch in #3 doesn't fix the problem with setting a default webform in the content type. The form is created but the fieldset element appears at the end, empty. Since my issue is caused specifically in the code for inserting default webforms in new nodes: webform_share_node_insert(), I've split that off into it's own issue: #2081745: Default Webform Fieldset Members Loose Their Assignment on Node Insert
Comment #12
roball CreditAttribution: roball commentedCan confirm #11 as a workaround. With the simple patch attached to that other issue, webform components will get properly populated when the WS-export code was pasted into the content type's "Web form default components" textarea box.
Comment #13
kevster CreditAttribution: kevster commented#1 worked for me and solved the missing fields in imported fieldsets - many thx!
Comment #14
roball CreditAttribution: roball commented@kevster: Did you mean #1 or #11? For me, the solution pointed out in #11 worked.
Comment #15
kevster CreditAttribution: kevster commentedHi @roball - #1 worked for me, I manually patched as was a simple change - I scrapped the curent form and started a new one and all went in ok.
Comment #16
cravecode CreditAttribution: cravecode commentedIt appears the main issue is caused by not tracking original parent component IDs to the new generated component ID. This leaves out nested components because the hierarchy can't be properly built by Webform.
Also because of potential nested components, the original method of getting the "next_cid" may fail causing "PDOException: SQLSTATE[23000]: Integrity constraint violation" errors.
Patches #1 and #3 did didn't fix the problem for me. I'm attaching a patch the tracks old "pid" to "cid" values and correctly sets them during the import. The patch also calls to the database to get the "next_cid".
I hope the OP doesn't mind but I updated the original issue summary with these additional details. I also linked other issues I believe to be related to this.
IMHO, this bug makes this module unusable in most situations. I hope my patch helps others.
Comment #17
cravecode CreditAttribution: cravecode commentedComment #18
cravecode CreditAttribution: cravecode commentedComment #19
cravecode CreditAttribution: cravecode commentedPosting a new patch after finding a bug when tested on our production environments. Don't use #16, use #19 instead.
Comment #20
FatherShawn@cravecode - this sounds like it could also address the related issue #2081745: Default Webform Fieldset Members Loose Their Assignment on Node Insert I'm looking forward to testing it!
Comment #21
mmkc CreditAttribution: mmkc commentedThis patch adds rules export and import capability to the webform_share module.
Comment #22
cravecode CreditAttribution: cravecode commented@mmkc thanks for the contribution! I'm a bit confused though, how is patch #21 related to this specific issue?
Comment #23
cravecode CreditAttribution: cravecode commentedComment #24
joseph.olstadPlease ignore comment #21, a new issue was created and a new patch for that is in the queue waiting for review.
Comment #25
Angry Dan CreditAttribution: Angry Dan at Deeson commentedHi,
The patch in #19 worked perfectly for me, so I've cleaned it up a little to meet Drupal coding standards and removed the unnecessary comments.
See attached!
Can we get this committed? This module could do with some TLC!
Comment #27
Alan D. CreditAttribution: Alan D. commentedI think that there is a small logical flaw here:
$cid = $next_id++;
Which would make $cid === max cid. So I think it should be this??
$cid = ++$next_id;
But pushed to dev.
Please report any issues.
Cheers everybody (and sorry for taking so long to get into the queues)
Comment #29
Alan D. CreditAttribution: Alan D. commentedOr maybe not? Was the $cid = ++$next_id; change inc things by one to many?