Notice: Undefined property: stdClass::$original in user_save() (line 555 of /modules/user/user.module).
Notice: Undefined property: stdClass::$original in user_save() (line 563 of /modules/user/user.module).
Steps...
1. upgrade to field_collection 7.x-1.0-beta12
2. add a field collection to a user
3. remove a field collection from a user
4. get the above errors
Seems like the $account->original variable is wrongly unset on the call to field_attach_update(). This is observed because $account->original is valid on line 542 of /modules/user/user.module, but then is unset after the call to field_attach_update() when referenced on line 555.
/modules/user/user.module lines 542 - 559
// If the password changed, delete all open sessions and recreate
// the current one.
if ($account->pass != $account->original->pass) {
drupal_session_destroy_uid($account->uid);
if ($account->uid == $GLOBALS['user']->uid) {
drupal_session_regenerate();
}
}
// Save Field data.
field_attach_update('user', $account);
// Send emails after we have the new user object.
if ($account->status != $account->original->status) {
// The user's status is changing; conditionally send notification email.
$op = $account->status == 1 ? 'status_activated' : 'status_blocked';
_user_mail_notify($op, $account);
}field_attach_update() calls numerous hooks as defined in the field_collection module. After a quick look I could not see where $account->original was unset by the field_collection module.
Comments
Comment #2
webservant316 commentedComment #3
webservant316 commentedReverting to field_collection 7.x-1.0-beta11 solves the problem. However, the revert is not a simple code copy because field_collection 7.x-1.0-beta12 installs some database updates.
Comment #4
webservant316 commentedComment #5
webservant316 commentedSorry this is not major, but normal. The error makes a lot of noise, but I think there is no harm.
Comment #6
jmuzz commentedI tried this with the latest dev version but I didn't see an error.
It has the fix from #2382089: Logic issue with fetchHostDetails() causes false "the host entity cannot be changed" error in updateHostEntity() but it didn't seem related to your error so I don't think this has been solved.
Can you provide more details about how it can be reproduced?
Comment #7
webservant316 commentedMy use case has a field collection defined for a particular node type and another field collection for the user profile. After upgrading from field_collection 7.x-1.0-beta11 to 7.x-1.0-beta12 I performed a few quick tests.
I opened an existing node and added a field collection ~ worked
I opened the same node and deleted the field collection ~ worked
I opened an existing user and added a field collection ~ worked
I opened the same user and deleted the field collection ~ errors as displayed above
The error is because $account->original was unset after the call to field_attach_update('user', $account). I am sure that field_collection hooks into that function.
Also as part of the upgrade I moved from Drupal 7.50 to 7.52. However, I diff shows that the user.module was not significantly changed in the Drupal upgrade.
What else can I do to test the error?
Comment #8
jmuzz commentedThanks @webservant316 . I tried a few more things and found that the error occurs when removing the final item but it seems to work if there are still some remaining items after one is removed.
Comment #9
webservant316 commentedyes, that makes sense.
Comment #11
jmuzz commentedShould be fixed now.
Please reopen if it doesn't work for you.
Comment #12
webservant316 commentedI'll check this out on my next round of updates. Might be awhile.
Comment #13
luisasasi commentedI have the same problem
1. upgrade to field_collection 7.x-1.0-beta12
2. add a field collection to a user
3. remove a field collection from a user
4. get the above errors
Reverting to field_collection 7.x-1.0-beta11 solves the problem, but now, when a user logs in, the system sends email:
how do I fix?
Comment #14
jmuzz commentedTry the latest dev version.
Comment #16
webservant316 commentedwhen is the next release scheduled for to push this fix into production?
Comment #17
danielb commented"The error makes a lot of noise, but I think there is no harm."
The effect here is that the user's status is mistakenly believed by user.module to be "blocked" and then reset to "active". This causes emails to be fired off (to customers in the case I'm investigating) there is a bit of harm there....
Comment #18
webservant316 commentedstill waiting for this fix to get pushed to production. what is the hold up?
Comment #19
rbrandon commentedAgreed that this needs a release. (https://www.drupal.org/project/field_collection/issues/2885870#comment-1...)
There are other implications, for example, the inadvertent save will cause Organic Group references to be deleted in some cases.
Comment #20
webservant316 commentedDrupal updates for me today and I see this is not ready yet. Just trying to push it along.
Comment #21
webservant316 commentedyayy field_collection 1.1 has this fix! thanks!