If I enter the same code twice I get a PDOException on the second entry. There should be a more graceful error message than this:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'temp8' for key 'code': INSERT INTO {regcode} (created, begins, expires, code, is_active, maxuses) 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); Array ( [:db_insert_placeholder_0] => 1394661983 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => temp8 [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => 1 ) in regcode_save() (line 494 of /....../sites/all/modules/regcode/regcode.module).
Comment | File | Size | Author |
---|---|---|---|
#4 | PDOException-when-duplicate-code-entered-2216681-11011829-7-x.patch | 2.17 KB | sh.manishshukla |
Comments
Comment #1
sh.manishshukla CreditAttribution: sh.manishshukla as a volunteer and commentedlooking into this..
Comment #2
sh.manishshukla CreditAttribution: sh.manishshukla as a volunteer and commentedHere is the patch..
Comment #3
bkaestner CreditAttribution: bkaestner as a volunteer commentedHey, I looked at your patch and I was getting a warning about getting properties from non-object.
Notice: Trying to get property of non-object in regcode_save()
I remedied the issues by adding this line to the if statement
This checks to see if the result from the query is empty before insert the a new code.
Hope this helps!
Comment #4
sh.manishshukla CreditAttribution: sh.manishshukla as a volunteer and commentedHi bkaestner,
I have updated the patch as per your suggestion.
Thanks,
Happy Drupaling
Comment #5
steinmb CreditAttribution: steinmb as a volunteer commentedNot sure I understand the motive here. Could anyone explain
?
Comment #6
TR CreditAttribution: TR commentedThis was fixed by #2781241: Required Patch for ajax validation, Remove PDOexception for already exists code and date fields to reduce +-15