Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Notice: Undefined property: stdClass::$uid in profile_user_presave() (line 218 of /home/berdir/Projekte/d7/drupal/modules/profile/profile.module).
Getting this for every user when creating users with devel_generate. It looks like profile assumes that there is always a uid in presave, that is imho wrong.
Comment | File | Size | Author |
---|---|---|---|
#8 | profile-crudtests-testsonly.patch | 1.26 KB | effulgentsia |
#8 | profile-crudtests-withfix.patch | 1.71 KB | effulgentsia |
#1 | profile_fix_notice.patch | 550 bytes | Berdir |
Comments
Comment #1
BerdirFix is simple.
Comment #2
klausiLooks good, patch fixes the notice.
Comment #3
dhthwy CreditAttribution: dhthwy commented#1: profile_fix_notice.patch queued for re-testing.
Comment #4
Damien Tournoud CreditAttribution: Damien Tournoud commentedIs that the correct fix? Why was this moved to hook_user_presave() instead of hook_user_update()? Let's discuss.
Comment #5
BerdirIt's the correct fix *for the php notice* ;)
I guess it's a totally different story if the code is in the right place. It probably *was* before the $user->data changes so that the information doesn't end up in {users}.data but we can probably move it to update now..
Comment #6
Damien Tournoud CreditAttribution: Damien Tournoud commentedHm. Ok, so that was a misunderstanding somewhere during the refactoring of {users}.data.
Because the profile module doesn't need to add stuff to {users}.data, it doesn't need to implement hook_profile_presave().
Let's change that :)
Comment #7
effulgentsia CreditAttribution: effulgentsia commentedThis changes the logic to call profile_save_profile() if uid=0. If that's not desired, can we use !empty() instead? Also, let's add a test for this. For example, EntityCrudHookTestCase::testUserHooks() is one of several existing tests that invokes user_save() on a $account object missing a uid, and it would currently trigger this notice and therefore fail if profile.module were enabled during that test run.
Powered by Dreditor.
Comment #8
effulgentsia CreditAttribution: effulgentsia commentedHere's a patch that adds tests to demonstrate the bug (should fail), and another patch with the same tests plus the fix (should pass).
This patch doesn't change that, so that it can be backported to D7. Once it lands, this issue can be continued with a D8-only refactoring of hook implementations.
Comment #9
ParisLiakos CreditAttribution: ParisLiakos commentedsubscribe..
i know it is just a notice, but for d7 the isset patch should be fine :)
Comment #10
marcingy CreditAttribution: marcingy commentedProfile no longer exists in d8.
Comment #11
rickmanelius CreditAttribution: rickmanelius commentedSo does the patch in #8 need to be re-rolled? The main part looks like a simple one-line change. Anyone test yet?
Comment #12
Berdir#8: profile-crudtests-withfix.patch queued for re-testing.
Comment #13
sah62 CreditAttribution: sah62 commentedI just ran into this same error in d7 when the Ubercart module creates a new user account as part of the purchase payment process. I've implemented the patch in #8 for now.
Comment #14
daroz CreditAttribution: daroz commentedPatch in #8 working here
Comment #15
rickmanelius CreditAttribution: rickmanelius commentedConfirmed patch #8 works as well. Given #13, #14, and now #15 all work. Marking RBTC.
Comment #16
webchickNormally we'd need some actual assertions here to pass the "core worthy" test. However, given that this module's been removed from 8.x, this seems adequate for the purposes of catching this bug, and gives a base to build from in the future if needed.
Committed and pushed to 7.x. Thanks!