Drupal 6.2
Profile module enabled, two profile fields created to load from LDAP data
pubcookie-6.x-1.1 enabled, configured to use LDAP

# user warning: Duplicate entry '27-5' for key 1 query: INSERT INTO profile_values (fid, uid, value) VALUES (5, 27, 'my department') in /home/web/html/sites/all/modules/pubcookie/pubcookie.module on line 180.
# user warning: Duplicate entry '27-6' for key 1 query: INSERT INTO profile_values (fid, uid, value) VALUES (6, 27, 'my phone number') in /home/web/html/sites/all/modules/pubcookie/pubcookie.module on line 180.

It appears that the empty profile fields are created before pubcookie tries to fill them and the INSERT statement doesn't set the value. I got rid of the warnings and filled the value fields by modifying the INSERT statement from

db_query("INSERT INTO {profile_values} (fid, uid, value) VALUES (%d, %d, '%s')", $data->fid, $user->uid, $pubcookie_record[$key]);

to

db_query("INSERT INTO {profile_values} (fid, uid, value) VALUES (%d, %d, '%s') ON DUPLICATE KEY UPDATE value = '%s'", $data->fid, $user->uid, $pubcookie_record[$key], $pubcookie_record[$key]);

but the MySQL manual says "you should try to avoid using an ON DUPLICATE KEY clause on tables with multiple unique indexes" like profile_values

Comments

pixlkat’s picture

Version: 6.x-1.1 » 6.x-1.2

Version 6.x-1.2 still gave me the same error. I looked in the profile.module file and noticed that before a record is inserted, a DELETE query is performed for the corresponding profile field. I added a delete query before the line in pubcookie.module that adds the field and the error went away and the value got added.