Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I just got this when creating a webform
Notice: Undefined index: pid in webform_component_insert() (line 717 of /Users/mike/shared/htdocs/dm7/sites/all/modules/contrib/webform/includes/webform.components.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'pid' cannot be null: INSERT INTO {webform_component} (nid, cid, pid, form_key, name, type, value, extra, mandatory, 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] => 1 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => first_name [:db_insert_placeholder_4] => First Name [:db_insert_placeholder_5] => textfield [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => a:4:{s:13:"title_display";s:6:"before";s:7:"private";i:0;s:8:"disabled";i:0;s:6:"unique";i:0;} [:db_insert_placeholder_8] => 0 [:db_insert_placeholder_9] => 0 ) in webform_component_insert() (line 726 of /Users/mike/shared/htdocs/dm7/sites/all/modules/contrib/webform/includes/webform.components.inc).
Comment | File | Size | Author |
---|---|---|---|
#12 | webform_pid_fix.patch | 1.74 KB | quicksketch |
#11 | webform_pid_fix.patch | 13.21 KB | quicksketch |
#8 | webform_pid_1765606.patch | 438 bytes | Liam Morland |
#6 | fixed_db_error_when_creating_component-1765606-6.patch | 1.48 KB | PatchRanger |
Comments
Comment #1
quicksketchWhen "creating" a Webform? That sounds unlikely, since no components are on new webform nodes (and the error is in webform_component_insert()). Is this when you add a new webform *component*? If not, how are you creating this webform (through UI, API, some other module)?
Comment #2
mgiffordI'll come back to this if I run into this error in the future. Not sure I can reproduce it yet.
Comment #3
jghyde CreditAttribution: jghyde commentedI confirm this error. It's in the Aug 30, 2012 edition of 7.x-3.x-dev. To fix, disable then uninstall webform and install the green (production) release.
To replicate:
1. Create a webform content node/add/webform
2. After filling out the title/body, click save.
3. Click on the "Webform" tab.
4. On the ensuing page, create a textfield, for instance, "First Name."
5. Click save.
6. You will be presented with the form with the details of the "First Name" textfield. Leave at defaults.
7. Click save. The PDO error appears.
Comment #4
quicksketch@jghyde Could you provide your PHP and MySQL version (assuming you're using MySQL)?
Comment #5
PatchRanger CreditAttribution: PatchRanger commentedConfirmed.
I use the latest 7.x-4.x dev.
Got exactly the same error message when tried to create the first component for webform.
PHP version 5.3.10-1ubuntu3.3
MySQL version 5.5.24-0ubuntu0.12.04.1
Comment #6
PatchRanger CreditAttribution: PatchRanger commentedLittle investigation resulted in this: webform_component.pid should be nillable - but it is not.
It should because of description it has : 'If this component has a parent fieldset, the cid of that component.'.
The word 'if' is the key: how it can be non-nillable if its value is conditional?
Please review the patch.
Don't forget to run update.php after patching.
Comment #7
Liam MorlandI am seeing this problem too. I get the error when I try to create a form component. I am using a fresh D7 install with today's Webform 7.x-4.x.
Looking at the database in existing installs, form components without a parent have the pid set to zero and the column is NOT NULL. Something must have previously set $component['pid'] = 0.
Comment #8
Liam MorlandThe attached patch fixes it for me. I just threw this together; there may be a better place to set the $component['pid'].
Comment #9
PatchRanger CreditAttribution: PatchRanger commented@Liam Morland Your patch works for me.
I appreciate your solution : my was doing the same but by very convoluted way:)
I think you have placed this checking to appropriate place.
Comment #10
quicksketchI think this problem was caused by #1762262: Option for "Parent fieldset" should not hinge on fieldsets alone, where we changed this conditional on the component_edit_form():
Previously this *always* equated to TRUE, since the "webform_enable_fieldset" variable doesn't actually exist. However without it, we now get this PDO error when adding the first component to a Webform node.
Comment #11
quicksketchThis patch also fixes the problem by removing the IF statement entirely around the parent fieldset option so that it always exists, basically making Webform behave like it did before #1762262: Option for "Parent fieldset" should not hinge on fieldsets alone.
Comment #12
quicksketchSorry lots of unrelated cruft in #11. Here's the patch.
Comment #13
quicksketchI committed #12 to undo my mistake in #1762262: Option for "Parent fieldset" should not hinge on fieldsets alone.
Thanks guys for catching this before I made a huge mistake with a new stable release of Webform 3.x. I hadn't noticed while I had Form Builder installed and was testing with existing installations. I'll roll out a new alpha of 4.x to undo this problem.
Comment #14
Liam MorlandWorks for me; thanks.
Comment #15
PatchRanger CreditAttribution: PatchRanger commentedWorks for me as well. Thanks a lot.