By editing first time poll content gives this error:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'NO' 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] => 4 [:db_insert_placeholder_1] => Yes [:db_insert_placeholder_2] => NO [:db_insert_placeholder_3] => 0 ) in poll_insert() (line 546 of C:\xampp\htdocs\drupal7\modules\poll\poll.module).
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 939880-D7-14.patch | 2.55 KB | amateescu |
| #14 | 939880-14-test-only.patch | 1.61 KB | amateescu |
| #14 | 939880-14.patch | 2.59 KB | amateescu |
| #13 | 939880-13-test-only.patch | 1.64 KB | amateescu |
| #13 | 939880-13.patch | 2.62 KB | amateescu |
Comments
Comment #1
furamag commentedI'm able to reproduce this bug. It looks like you added 'No' to 'Vote count' field and validation doesn't work for this field in some reason.
Comment #2
furamag commentedThere is bug in function poll_insert in poll.module. We are using following code (line 537):
To fix bug we should use updated code:
Comment #3
Wolfflow commentedThanks @furamag for feedback, going to apply code.
Comment #4
amateescu commentedComment #5
amateescu commentedThe solution here is to fix the validation, not the database insert.
Attached patch cleans up this mess and applies cleanly to D7 and D8. I promise to follow up with tests in #295993: TestingParty08: Poll form validation :)
Comment #6
amateescu commentedRe-rolled to take http://drupal.org/node/1274212#comment-4973492 into account.
Comment #7
amateescu commentedThe string changes were not accepted for D7, so here's another patch that keeps the string and reuses one from number.module.
Again, I'd recommend to postpone this until #1274212: Incorrect order of choices in Poll module. is fixed.
Comment #9
marcingy commentedCan't we just use element_validate_integer_positive as an element validator?
Comment #10
marcingy commentedComment #11
marcingy commentedThis really also needs tests.
Comment #13
amateescu commented@marcingy: good idea, but element_validate_integer instead of element_validate_integer_positive because the vote count can be 0.
Comment #14
amateescu commentedI asked @chx in IRC to validate the test-only patch, and the only 'complaint' was that we don't need to logout the admin user because login does it for us.
So, new patches for review (It's sad that I can't stop the testbot from reviewing the previous ones..), and if everythings checks out, I'm going to RTBC based on the idea from #9 and the validated tests :)
Comment #15
amateescu commentedRTBC it is then.
Comment #16
catchThanks. Committed/pushed to 8.x. Moving to 7.x for backport.
Comment #17
amateescu commented7.x patch.
Comment #18
webchickCommitted and pushed to 7.x. Thanks for the fix, and the test!
Comment #21
George Bills commentedShouldn't the code also include #required => true?
Otherwise saving a poll node form with no values in the "count" fields gives "PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'chvotes'".
Comment #22
secretsayan commentedOk! Right!
So just added '#required => True' in line 412
Comment #23
mgiffordWe still need to D7 patch to review so changing the status.