Profile Export CSV - Missing field data

Verna - July 10, 2009 - 00:30
Project:Profile CSV
Version:5.x-1.0
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I installed profile_csv module, configured profile_csv settings and ran the export csv function. The csv file exported and all profile fields were represented, however data was not present in the last 6 out of the total 31 profile fields. The total file size is only around 400kb with around 1800 records. The fields missing data were the most recently added profile fields, however when these profile fields are viewed on the website, the field data is infact there.

I'm not a Drupal programmer and quite new to the system. Hoping there may be a relatively simple solution why all of the data is not being exported into the csv file.

#1

Verna - July 10, 2009 - 22:20
Assigned to:Verna» Anonymous

#2

Verna - July 10, 2009 - 00:54

I played with changing the visibility of these fields from hidden to private and the data is now present in the export csv file. However, I can't leave these fields as 'private' as it allows the user to modify the contents. Is the solution now code based?

#3

ProNotion - August 6, 2009 - 15:45

I have the same issue. I don't/can't really allow the hidden fields to be visible to the end user just so they can be included in the export.

#4

netsensei - September 10, 2009 - 19:29

Saw the same here, so I went digging... It seems that Profile module stores it's data in two places: as an unserialized strings in the users table or in the profile_values and profile_fields table.

I don't really get the rationele behind dispersing your data like that but has something to do with the visibility of the fields.

Anyway, Profile export CVS isn't really anticipating where to look for data. So around line 247 in profile_cvs.module I changed the code to this:

  foreach ($profile_fields  as $profile_field) {
    // Try to get it from the $user_data
    $value = $user_data[$profile_field['name']];
  
    if (empty($value)) {
      $value = db_result(db_query("SELECT pv.value
        FROM {profile_fields} pf, {profile_values} pv
        WHERE pv.fid = pf.fid
        AND pf.name = '%s'
        AND pv.uid = %d", $profile_field['name'], $uid));
    }
  
    if ($profile_field['type'] == 'date') {
      if ($value !== 0) {
        $value = unserialize($value);
        $value = $value['year'] .'-'. $value['month'] .'-'. $value['day'];
      }
    } 
    $profile_result[] = $value;
  }

Basically throws out the whole visibility stuff. Instead, it just goes fallback: if it doesn't find the data in the users['data'] array, it goes tries to fetch data from the profile_* tables. Blunt, primitive,... but at least it gets the job done and returns *all* the data.

 
 

Drupal is a registered trademark of Dries Buytaert.