Hi,

I have enabled Profiles on my site (for alumnis) and added the fields:
- profile_first_name and profile_first_name (category 'Personal info')
- profile_grad_year_high_school and profile_class_year_high_school (category 'School related info').

I then imported some users using a CSV file with the fields username, email, lastname, firstname, graduationyear, class and password.
(There's an error message saying a temporary file could not be deleted in from the tmp directory (\includes\file.inc file on line 468) but I guess this has nothing to do with the problems I experience.)

All the users are imported and all info seems to be okay when I look at the user profiles.

But when I open a View that selects alumnis by year and class, all users appear 4 times!! (Once with last name and first name, once with last name only, once with first name only and once with none of both.)

You can find a screenshot at http://www.pedrotytgat.be/temp/view_1.png

I started looking around in the mysql tables and found that the profile_values table also holds every user 2 times, where each field ID has a filled in and an empty value.

Screenshot at http://www.pedrotytgat.be/temp/profile_values_1.png

I discovered that editing the user profile kind of consolidates things. When I change the first and last name (fields belonging to the category 'Personal info'), two entries disappear in the profile_values table:

See http://www.pedrotytgat.be/temp/profile_values_2.png

Immediately, the View yields the correct result:

See http://www.pedrotytgat.be/temp/view_2.png

Changing the graduation year and class removes the two other redundant fields in the table.

See http://www.pedrotytgat.be/temp/profile_values_3.png

Of course, the View is still correct:

See http://www.pedrotytgat.be/temp/view_3.png

I am using Drupal 5.2, using a local mysql and apache server (using the "portable WOS" application suite).

Thank you for any help,

Pedro

Comments

saviles’s picture

I am having the same issue, only records are appearing 4 times since I have 4 profile fields. Did you ever resolve this?

ferrangil’s picture

Assigned: Pedro_Tytgat » Unassigned

Some people (also me) with the same problem, but instelad of using Views, using Site User List, but the problem must be when importing...
http://drupal.org/node/198282

ferrangil’s picture

Status: Active » Fixed

Guys (and girls??),
I managed to fix that in my case. Please take a look at:
http://drupal.org/node/174322
The bug is still unresolved, but at least you could have your user list without duplicates.
Have fun!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

davidwhthomas’s picture

Status: Closed (fixed) » Fixed

The fix above was specific to that users field ids etc...

For anyone having issues with duplicate entries in the profile_values table for users when using user_import:

I ran some tests and it looks like the issue arises when hook_user is called by the profile module when the user is saved. I don't think it's passed the profile values in the way it expects and so profile_save_profile inserts a blank record into profile_values for that user, along with the one inserted by user_import.

To solve this, I (temporarily) commented out the case 'insert': line in profile_user
To comment out a line, simply add two forward slashes i.e: // in front of the line, converting it to a code comment

/modules/profile/profile.module line 177

<?php
/**
 * Implementation of hook_user().
 */
function profile_user($type, &$edit, &$user, $category = NULL) {
  switch ($type) {
    case 'load':
      return profile_load_profile($user);
    case 'register':
      return profile_form_profile($edit, $user, $category, TRUE);
    case 'update':
      return profile_save_profile($edit, $user, $category);
    case 'insert':
      //return profile_save_profile($edit, $user, $category, TRUE); //comment out this line!
    case 'view':
      return profile_view_profile($user);
    case 'form':
      return profile_form_profile($edit, $user, $category);
    case 'validate':
      return profile_validate_profile($edit, $category);
    case 'categories':
      return profile_categories();
    case 'delete':
      db_query('DELETE FROM {profile_values} WHERE uid = %d', $user->uid);
  }
}
?>

Remember to uncomment the line when you've finished importing or else the profile module will not work properly

I hope it works for you too.

Note: It would be possible to fix this issue in user_import.module (version 5.x-1.3) by adding the profile fields to the $account object before it is saved with user_save('', $account); //line 1588
That way, the profile module will handle saving the profile fields, avoiding this blank field error.

robert castelo’s picture

Status: Fixed » Active
robert castelo’s picture

Status: Active » Fixed

Fixed in 5.x-2.0-beta2.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.