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.

CommentFileSizeAuthor
#3 patch_25839 bytesdarius
patch_22654 bytesdarius
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

darius’s picture

Version: 4.7.0-beta3 » x.y.z

This issue is still there in 4.7-beta 4. Patch still applies to CVS version.

Darius

Dries’s picture

IMO, this needs fixing in the caller.

darius’s picture

FileSize
839 bytes

OK, how about this patch?

Darius

Barogio’s picture

darius that patch works however there are other references to the same function in profile.module so those might need to be changed also.

darius’s picture

I 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.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

looks right to me. i didn't test but is trivial.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)