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).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

When "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)?

mgifford’s picture

Status: Active » Postponed (maintainer needs more info)

I'll come back to this if I run into this error in the future. Not sure I can reproduce it yet.

jghyde’s picture

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

quicksketch’s picture

@jghyde Could you provide your PHP and MySQL version (assuming you're using MySQL)?

PatchRanger’s picture

Status: Postponed (maintainer needs more info) » Active

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

PatchRanger’s picture

Status: Active » Needs review
FileSize
1.48 KB

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

Liam Morland’s picture

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

Liam Morland’s picture

FileSize
438 bytes

The attached patch fixes it for me. I just threw this together; there may be a better place to set the $component['pid'].

PatchRanger’s picture

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

quicksketch’s picture

I 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():

-  if (variable_get('webform_enable_fieldset', TRUE) && is_array($node->webform['components'])) {
+  if (!empty($node->webform['components'])) {

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.

quicksketch’s picture

Priority: Normal » Major
FileSize
13.21 KB

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

quicksketch’s picture

FileSize
1.74 KB

Sorry lots of unrelated cruft in #11. Here's the patch.

quicksketch’s picture

Title: PDOException: SQLSTATE[23000] when creating form » PDOException: SQLSTATE[23000] when adding first component to a node
Status: Needs review » Fixed

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

Liam Morland’s picture

Works for me; thanks.

PatchRanger’s picture

Works for me as well. Thanks a lot.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.