Profile module don't check empty value or not and just save all edited fields to `profile_values` table. It's not critical, but promote problem, which I explain below on example from my site.

On my site devoted to one roleplay game users stored their player group names in profile field 'players_of' with type 'freeform list'. I can select them by group: "profile/players_of/". It works ok. Then, seems logical to separate players from nonplayers with request "profile/players_of/" and get all users, who wrote something in his 'players' field. But instead we get all accounts, which was edited once or more - because profile module stores empty field values too. If I made DELETE FROM {profile_values} WHERE VALUE='', then request "profile/players_of/" returns what I want ...but until any user update his profile.

Now I made workaround as separate module - just delete all empty records from `profile_values` on every user update (function used hook_user). But will good if such check will made inside profile module.

CommentFileSizeAuthor
#4 profile_77616.patch584 bytesjurgenhaas
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

magico’s picture

Version: 4.7.3 » x.y.z

Confirmed in HEAD.

Anyway, is not wrong when the profile module saves all fields (even if they are blank); but it could have a tweek, to not happen...

lilou’s picture

Version: x.y.z » 7.x-dev

This bug is it still valid ?

Jody Lynn’s picture

Status: Active » Closed (won't fix)

You could argue that when a user leaves a field blank on a profile that that is a kind of data to store.

jurgenhaas’s picture

Status: Closed (won't fix) » Active
FileSize
584 bytes

I have to reopen this isue as it bugs me in the following scenario:

From my own module I need to modify just one single profile field and I'm doing this with the following code

<?php
  $account = [given as a valid account with existing id];
  $edit = array();
  $edit['profile_my_field'] = 'my value';
  user_save($account, $edit, 'MyCategory');
?>

This is then calling profile_save_profile(&$edit, $account, $category) and that load all fields from the given category and merges them with the given values in $edit.

The problem is that lots of values are not given in $edit and that leads to a lot of warnings in dblog or elsewhere, depending on log settings.

I think the db_merge() should be conditional and check if the field if given in $edit. Applied is a patch doing exactly this.