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.
Comment | File | Size | Author |
---|---|---|---|
#4 | profile_77616.patch | 584 bytes | jurgenhaas |
Comments
Comment #1
magico CreditAttribution: magico commentedConfirmed 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...
Comment #2
lilou CreditAttribution: lilou commentedThis bug is it still valid ?
Comment #3
Jody LynnYou could argue that when a user leaves a field blank on a profile that that is a kind of data to store.
Comment #4
jurgenhaasI 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
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.