I am receiving this error when creating a user without an access code. If I create a user with an access code then there is no error.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'PRIMARY': INSERT INTO {access_code} (uid, code, expiration) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 25 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => 1390366799 ) in access_code_user_insert() (line 215 of /sites/all/modules/access_code/access_code.module).

Any ideas?
thanks

Comments

rudy2342’s picture

I add this before the db_insert on line 208. Seems to working fine now. Curious to see if anyone else had this issue.

if(!empty($account->access_code)){

hyperlinked’s picture

I've incorporated this into my patch against issue #2265509:
https://drupal.org/node/2265509

You can apply that patch to fix this. I've also added a uniqueness check to the validation function so you won't get this same error if you accidentally used the same code twice.

hyperlinked’s picture

Assigned: Unassigned » hyperlinked

glekli’s picture

Status: Active » Fixed

This issue has been addressed.

hyperlinked’s picture

Status: Fixed » Closed (fixed)

Verified. Closed.