The current profile field code for master doesn't work because the profile module sets the field to null so the check for isset($array[$type]) will fail.

Comments

greggles’s picture

Status: Active » Needs review
StatusFileSize
new1.24 KB

And a fix. I feel like loading a user is not a big deal. Also, the normal process of saving an account page already does load a lot of times so this isn't a big change to load it once more.

greggles’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs review » Patch (to be ported)

killes approved this in irc and it's now committed: http://drupal.org/cvs?commit=432390

We'll need to review this for D7 at some point but it may work there. Updating status/version for tracking.

greggles’s picture

Title: profile fields don't actually synch » Synch all profile fields on every edit of user account
Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Patch (to be ported) » Needs review
StatusFileSize
new952 bytes

I realize now that this is insufficient. We can't ask people "please edit your account and change every value and then change it back to what it should be" just to get the data synched down to the slave sites.

I think we should send all profile data marked as ready for synch on every edit.

juliangb’s picture

#3 seems logical.

greggles’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs review » Patch (to be ported)

Thanks, Juliangb - now committed http://drupal.org/cvs?commit=433282

greggles’s picture

A weird situation: the values don't seem to get saved into the profile_fields on groups.drupal.org until/unless the user edits their profile and saves it. Instead the data is stored in users.data. On chicago2011.scratch.drupal.org it works fine.

robbiethegeek’s picture

It seems that when you go through this that you need to actually edit (actually make a change to a field) and save it http://groups.drupal.org/user/274979 had this issue and we went through this process.

greggles’s picture

@robbiethegeek, thanks for the additional debugging details. I disabled the synch feature for g.d.o earlier today since someone had the problem and they worked with me in irc and we were unable to get it working properly. We're rolling out a new version of bakery to all the sites tomorrow, and updating g.d.o in general in the next two months - we can just try it out again and see if that somehow fixes it...

greggles’s picture

Version: 7.x-1.x-dev » 6.x-2.x-dev
Status: Patch (to be ported) » Needs work

If we want to use user_save then we have to:

1) we have to load up all the profile fields on the site and make sure they are populated in the $user object even if they weren't sent in the stroopwafel
2) we have to loop over the potential $categories and call each one of them
3) we have to normalize the incoming data to adjust for cases where the "full_name" field on master is in a different profile category than it's in on the slave

Instead, I suggest we manually save the profile fields directly to profile_values and unset them before calling user_save and probably call user_save with just the category that is set on user/uid/edit (i.e. not a profile page).

coltrane and drumm agreed to this conceptually in irc. I'm documenting it here so I remember what to do and so others can comment on the proposed system.

greggles’s picture

Status: Needs work » Needs review

OK, I think the attached patch will work.

Some tests I did:
1. Create profile fields on master in "a category".
2. Create matching fields on the slave in "a different category"
3. With a user that has accounts on both sides, edit/save their main account page, their "a category" page, any other page on their profile

Expected results: data is synched into profile fields and nothing extra is left is users.data.

1. Blank out a profile field on master.
Results: confirm it is blanked out on the slave.

greggles’s picture

StatusFileSize
new2.75 KB

coltrane informs me this needs moar patch.

coltrane’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.87 KB

Revised patch, removing leftover watchdog debug and checking if profile module exists in bakery_get_profile_fields(). My testing showed this working well. RTBC with final signoff from greggles.

I'll be opening a followup issue about a new bug. If you have mixed Bakery synced profile fields on the same category and save the form on slave you lose all the values.

greggles’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed with a slight cleanup to the description of the bakery_get_profile_fields function since they key/value got changed mid work and I never changed the description http://drupal.org/cvs?commit=451820

Thanks for the review/fixups, Ben!

purencool’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (outdated)