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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

donutdan4114’s picture

Status: Active » Needs review
FileSize
486 bytes

Wow, nice find. Fixed quite simply. Epic patch.

donutdan4114’s picture

Added test.

donutdan4114’s picture

Anonymous’s picture

Version: 7.22 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.