Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If some of public user profile fields are empty, instead of showing nothing, the user list displays values of a previously listed user. The problem is in the the folloiwing function, where $fields argument is already initialized to previous user values.
/**
* Helper function: update an array of user fields by calling profile_view_field
*/
function _profile_update_user_fields($fields, $account) {
foreach ($fields as $key => $field) {
if ($value = profile_view_field($account, $field){
$fields[$key]->value = $value;
}
}
return $fields;
}
A quick fix is to change the if line to if (($value = profile_view_field($account, $field)) || $value == '')
. However, the if clause could probably be eliminated altogether. In that case, the whole function might be redundant.
Comments
Comment #1
darius CreditAttribution: darius commentedThis issue is still there in 4.7-beta 4. Patch still applies to CVS version.
Darius
Comment #2
Dries CreditAttribution: Dries commentedIMO, this needs fixing in the caller.
Comment #3
darius CreditAttribution: darius commentedOK, how about this patch?
Darius
Comment #4
Barogio CreditAttribution: Barogio commenteddarius that patch works however there are other references to the same function in profile.module so those might need to be changed also.
Comment #5
darius CreditAttribution: darius commentedI think the other two references deal with listing a single user's data (as opposed to going through the list of users), so those cases are fine. The bug manifests itself when
$fields
array retains previous user's data when going through a list of users.Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentedlooks right to me. i didn't test but is trivial.
Comment #7
Dries CreditAttribution: Dries commentedCommitted. Thanks.
Comment #8
(not verified) CreditAttribution: commented