I need little help with fixing this error :
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'cid' at row 1: INSERT INTO {webform_submitted_data} (nid, sid, cid, no, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => 20 [:db_insert_placeholder_1] => 846 [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => ) w webform_submission_insert() (linia 133 z /sites/all/modules/webform/includes/webform.submissions.inc).
First page of the multipart form in question contains only markup components. Now, when someone saves a draft on this first page, proceeds with next pages and then tries to save a draft that error message comes up.
Problem lies somewhere in this query from function webform_submission_insert() :
foreach ($submission->data as $cid => $values) {
foreach ($values['value'] as $delta => $value) {
db_insert('webform_submitted_data')
->fields(array(
'nid' => $node->nid,
'sid' => $submission->sid,
'cid' => $cid,
'no' => $delta,
'data' => is_null($value) ? '' : $value,
))
->execute();
}
It looks to me that the after saving a draft of the first page $cid is empty because the form has no data then yet ...
Temporarily I have removed "Save a draft" button from first page with a bit of custom theming but still any help is welcome. Thanks!
Comment | File | Size | Author |
---|---|---|---|
#5 | webform_empty_draft_data.patch | 808 bytes | quicksketch |
Comments
Comment #1
quicksketchThanks, excellent report! Did you have on the "Automatically save drafts between pages" option? Or did the problem only occur when they clicked "Save Draft" manually?
In either case I can probably figure this issue out next time I'm working on Webform. Thanks for the report.
Comment #2
athanor CreditAttribution: athanor commented"Automatically save drafts between pages" option was off.
I will try with hidden field on that first page, see if that's make a difference.
Comment #3
Dustin Wyatt CreditAttribution: Dustin Wyatt commentedI also get this when I have only a markup component on a webform page with "Automatically save drafts between pages" on. Adding a hidden field component doesn't solve the problem.
Comment #4
johnshortessWe've seen three occurrences of this error on one of our sites, on a complex multipage form. In at least two of those cases, we've confirmed that the user started a new form, then clicked "Save as Draft" before actually entering any data (and in all three cases, the draft that was saved was completely blank).
This form will only be up for another week, but I'm going to try to do some debugging between now and then, and possibly even try my hand at a patch.
Comment #5
quicksketchI've confirmed the problem on both D6 and D7. This patch should fix both versions.
Thanks everyone for the excellent reports, sorry I didn't get to fixing this earlier.
@johnshortess had it right when he stated, "in all three cases, the draft that was saved was completely blank". This was the source of the problem. When we load the draft submission back out of the database, we weren't properly loading $submission->data as an empty array. Instead we were putting an array that was formatted like this:
Then when trying to save that data we got the nasty PDO error. So the problem wasn't in our data saving, it was in our loading. I've committed this patch to both 3.x branches and it should be in the soon-to-be release of 3.15.
Comment #6
johnshortessThank you very much! This patch appears to fix the problem. I've just pushed the patch to production -- I'll keep a close eye on watchdog (and emails from our client) for the next few days, and post here if I notice anything unusual.
Comment #7
quicksketchThanks for the follow up @johnshortess, very appreciated.