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.
I noticed that with invite_notification turned on, when a user edits his/her own profile and saves with a picture, the picture field is null after invite_notifications_init().
As it turns out, doing this:
global $user;
user_save($user, array('data' => array('notification_received' => FALSE)));
will kill the picture value, since the global $user's $user->picture contains the fid rather than the file reference itself.
When a user saves changes to another user with a picture, the picture isn't removed, but the acting user's picture is.
Comment | File | Size | Author |
---|---|---|---|
#2 | user_load_not_global_user-2292075-2.patch | 1.33 KB | franksj |
#1 | user_load_not_global_user-2292075-1.patch | 545 bytes | franksj |
Comments
Comment #1
franksj CreditAttribution: franksj commentedI changed the invite_notifications_init() to load a user object rather than use the global $user.
Patch included.
Comment #2
franksj CreditAttribution: franksj commentedChanged from updating $user to a new $account.
Comment #3
chobart CreditAttribution: chobart commentedPatch from #2 works. Thank you!
Comment #4
kerasai CreditAttribution: kerasai commentedGood to go.
This bug occurs because the global $user is not a fully-populated user entity, and one of the discrepancies is the data structure behind $user->picture. The patch from #2 fixes the issue by loading the full user entity and saving that.
Comment #5
djween CreditAttribution: djween commentedAfter much time pulling out hair and reading through many many many issue queues of other modules and core, it turns out this module seems to be culprit for the user pic issue on my site too. Patch applied and so far so good.
Comment #6
ckngCommitted to dev.