When submitting the node/add/poll form, if a Vote count field is empty (which is not expected) we end up with a PDOException as it tries to insert an empty string into an INTEGER field (which cannot be NULL nor empty)
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'chvotes' at row 1: INSERT INTO {poll_choice} (nid, chtext, chvotes, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 45 [:db_insert_placeholder_1] => Choice 1 [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => 1 ) in poll_insert() (line 562 of /.../modules/poll/poll.module).
On the function _poll_choice_form the chvotes field is validated by using element_validate_integer which throws an error only when the validated field is not empty.
I would suggest to set this field as required or to change the #element_validate callback in order to check if the field is empty before trying to insert it into the database.
Comment | File | Size | Author |
---|---|---|---|
#2 | d7-require_vote_count-1988168-2.patch | 1.34 KB | donutdan4114 |
#2 | interdiff.txt | 1.06 KB | donutdan4114 |
#1 | d7-require_vote_count-1988168-1.patch | 486 bytes | donutdan4114 |
Comments
Comment #1
donutdan4114 CreditAttribution: donutdan4114 commentedWow, nice find. Fixed quite simply. Epic patch.
Comment #2
donutdan4114 CreditAttribution: donutdan4114 commentedAdded test.
Comment #3
donutdan4114 CreditAttribution: donutdan4114 commented#2: d7-require_vote_count-1988168-2.patch queued for re-testing.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commented#1: d7-require_vote_count-1988168-1.patch queued for re-testing.