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.
This report applies to using the 1342632 dev branch in git (see #1342632: Deprecate OG group entity).
If a module calls user_save() on the currently logged in global $user object, there is a slew of error messages and the user's memberships to any groups are deleted. If the user is not a member of any groups and this happens, there are no errors.
This is using the latest og 1342632 branch and associated entityrelationships 1343854 branch.
Here is the list of errors that shows up:
- Notice: Trying to get property of non-object in OgBehaviorHandler->load() (line 27 of/mnt/SDData/web/www/html/.../sites/all/modules/og/plugins/entityreference/behavior/og_behavior.inc).
- Notice: Trying to get property of non-object in OgBehaviorHandler->load() (line 28 of/mnt/SDData/web/www/html/.../sites/all/modules/og/plugins/entityreference/behavior/og_behavior.inc).
- Notice: Trying to get property of non-object in OgBehaviorHandler->groupAudiencegetDiff() (line 97 of/mnt/SDData/web/www/html/.../sites/all/modules/og/plugins/entityreference/behavior/og_behavior.inc).
- Notice: Trying to get property of non-object in OgBehaviorHandler->load() (line 27 of/mnt/SDData/web/www/html/.../sites/all/modules/og/plugins/entityreference/behavior/og_behavior.inc).
- Notice: Trying to get property of non-object in OgBehaviorHandler->load() (line 28 of/mnt/SDData/web/www/html/.../sites/all/modules/og/plugins/entityreference/behavior/og_behavior.inc).
- Notice: Trying to get property of non-object in OgBehaviorHandler->groupAudiencegetDiff() (line 97 of/mnt/SDData/web/www/html/.../sites/all/modules/og/plugins/entityreference/behavior/og_behavior.inc).
- Notice: Trying to get property of non-object in OgBehaviorHandler->groupAudiencegetDiff() (line 100 of/mnt/SDData/web/www/html/.../sites/all/modules/og/plugins/entityreference/behavior/og_behavior.inc).
- Notice: Trying to get property of non-object in OgBehaviorHandler->groupAudiencegetDiff() (line 108 of/mnt/SDData/web/www/html/.../sites/all/modules/og/plugins/entityreference/behavior/og_behavior.inc).
- Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in EntityAPIController->load() (line 184 of/mnt/SDData/web/www/html/.../sites/all/modules/entity/includes/entity.controller.inc).
Comments
Comment #1
paul2 CreditAttribution: paul2 commentedJust going to throw this out there, I may be totally wrong:
Could it have to do with the fact that the field_data_og_group_ref table never gets populated with records when I add users to groups? I've always wondered why that table remains empty no matter how many user-to-group and node-to-group associations I have in the system, even though they are all using the og_group_ref field. In Views, for example, I've tried using og_group_ref to figure out group membership relationships but they never work because that table remains empty. Instead, I've had to rely solely on the og_membership table to determine these associations.
Perhaps during user_save(), the contents of field_data_og_group_ref are getting enumerated, and being that it's totally empty, it assumes that user is not a member of any groups and updates the contents of the og_membership table accordingly? Just a thought...
Comment #2
amitaibuI can't reproduce that. Have you tried it on a clean installation?
(Let's keep priority normal, as this branch isn't out yet, and is known to be a work in progress).
Comment #3
paul2 CreditAttribution: paul2 commentedOkay, trying to reproduce it on a fresh install... so far no luck here, either! Will post another update soon as I find anything out.
Comment #4
amitaibuOk, closing for now.
Comment #5
paul2 CreditAttribution: paul2 commentedTo anyone who needs help with this, I think I managed to fix it. I uninstalled OG and entityreference completely (which involves deleting any OG-related fields from all entities), deleted the module directories, inspected the database and removed any leftover remnants of OG and ER that I could find (including tables, field definitions, and whatever else - there were a few bits here and there), cleared the cache, then "git clone"d the OG and ER branches again, re-enabled the modules, and recreated the group properties on my entities. I am no longer getting these weird errors when a non-admin user that is a member of groups logs in.Edit: this is irrelevant now... see ticket description.
Comment #6
paul2 CreditAttribution: paul2 commentedActually... I spoke too soon! It is totally still happening - I just hadn't logged in again for a while. Sigh... Narrowing down the problem... will post an update soon!See issue description.
Comment #7
paul2 CreditAttribution: paul2 commentedGosh.. never mind. I finally found the source of the errors. It's a module I've written. Must be written poorly. Really sorry for the hassle, @Amitaibu!See issue description.
Comment #8
paul2 CreditAttribution: paul2 commentedI've narrowed down this problem further. I believe my module is written properly. What my module does is very simple. It hooks into hook_user_login(), tweaks one or two fields on the user account that is being logged in (basically syncing some fields from a remote service), then saves the user object using user_save(). In fact, not even changing any fields at all on the account, but simply re-saving the global $user object causes this slew of errors (and the user gets kicked out of all groups they were a member of).
See if it happens for you:
Comment #8.0
paul2 CreditAttribution: paul2 commentedHiding confidential information from summary
Comment #9
amitaibuI can't reproduce.
Comment #10
paul2 CreditAttribution: paul2 commentedOkay. Well I've just worked around it for now by using direct SQL queries to update user records. When I have more time again I'll try to come up with a comprehensive step-by-step procedure to reproduce this!
Comment #11
therainmakor CreditAttribution: therainmakor commentedPlease see https://drupal.org/node/1226586#comment-7610001 for a possible solution.
Comment #11.0
therainmakor CreditAttribution: therainmakor commentedMaking ticket description reflect current behaviour.