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.
When a group has been deleted, but the user still has a reference to the gid. When creating group content for another group I get a
"EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids()" error.
This is coming from the og_group_ref field widget when its checking og_is_group() for the available options.
I was able to get around this by checking if the $entity variable is not false before calling entity_extract_ids() in the og_is_group() function.
a patch is attached.
Comment | File | Size | Author |
---|---|---|---|
#16 | check-if-group-is-object-2900273-16.patch | 604 bytes | dharizza |
#14 | interdiff.txt | 368 bytes | plach |
#14 | og-entity-malformed-exception-after-deleting-group-2900273-14.patch | 5.46 KB | plach |
| |||
#10 | og-entity-malformed-exception-after-deleting-group-2900273-10.patch | 5.51 KB | MegaChriz |
#7 | node-access-stack-trace.txt | 36.99 KB | MegaChriz |
Comments
Comment #2
Xilis CreditAttribution: Xilis at BigScreen Group commentedI cannot reproduce, clean install, added 2 groups (and 1 group content for each group).
Deleting a group does as you say leave the reference in user object (og_user_node), however I am not getting any errors when trying to create new group content (the deleted group is simply not listed under group audience).
Comment #3
alesr CreditAttribution: alesr at BigScreen Group commentedComment #4
duqtape CreditAttribution: duqtape commentedI just wanted to chime in even though this issue has been closed. After quite a bit of poking through the database, I found I was getting this exact error because there were deleted group names/fields still present in the "og_memebership" table/"field_name" field. Once I deleted the offending rows in the table, the error went away.
Hopefully this helps someone else.
Comment #5
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedI get the provided error as well on
og_is_group()
. While trying to reproduce that error on a clean install I managed to get an EntityMalFormedException in a different way. This timeog_group()
failed.Steps to reproduce the failure in
og_group()
:Boom! EntityMalFormedException.
Note: after flushing caches, there is no longer an EntityMalFormedException when editing and saving the group content.
Attached a test that more or less follows above steps.
I'm hoping to find out how to reproduce it for
og_is_group()
as well.Comment #6
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedChanged title to better reflect differences with #1559766: EntityMalformedException when deleting users, in og_get_user_roles().
Comment #7
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedOkay, I got a EntityMalformedException in
og_is_group()
reproduced as well! Steps are similar to what I described in #5.Steps:
node_access()
call. For example a View with your own nodes that includes a Views edit link (views_handler_field_node_link_edit).Boom! EntityMalformedException!
I added a test to demonstrate the exception with a
node_access()
call.Also attached: stack trace (result of the test).
Comment #8
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedHm,
testGroupContentNodeAccessAfterDeletingGroupAndWhenUsingQueue()
did not fail on the testbot while it did locally.Let's try that again, but then using an actual page.
Comment #9
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedI made some mistakes in the last test. It would not pass when the bug would have been fixed.
Comment #10
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedAfter inspecting the stack trace for
testEditGroupContentAfterDeletingGroup()
it looks like that results into the issue inog_is_group()
as well, which means that what I did manually in #5 is not properly covered by an automated test yet. But that could be handled in a follow-up as well.Attached tests + fix for
og_is_group()
.Comment #11
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedGreat! Tests are passing. I created a pull request of the patch in #10:
https://github.com/Gizra/og/pull/429
Comment #12
jacob.embree CreditAttribution: jacob.embree at St. Louis Integration commentedhttps://github.com/Gizra/og/pull/429 has been merged into 7.x-2.x on GitHub which is great. It still needs to be synced back to Drupal.org. We should probably leave this at "Reviewed and tested by the community" until that happens.
@MegaChriz, is #1673472: Deleting groups does not delete the group member users group audience references to the group the followup you're talking about? Is anything other than that remaining?
Comment #13
Anaconda777 CreditAttribution: Anaconda777 commentedHi,
I applied the patch 10# to version 7.2.10 and the error went away.
My question is, is this related to same issue which did not went away:
In short, when a group has members, and the group node is deleted by site admin using a views which has a delete link,
the user data is not removed from the "og_membership" table and the user is not able to join to a new group.
The problem does not exist when the group admin deletes the node
or when the site admin deletes the group node from the Drupal core content -list.
To reproduce:
1. Create a node A which is a group. Add a user X to the group.
2. Create a views table (content) which has a list of group nodes and add a delete link
3. Delete the node A using the views delete link.
The problem: The user X data in the "og_membership" table is not removed.
This causes a problem; the user X is not able to join to any group.
Everything works when the group node is deleted by the group admin (from the node/edit page)
or by the site admin from the Drupal core content list "delete" link.
Is this a bug in OG or in my views ?
EDIT: removed the VBO mentioned, same problem comes just with the delete link -field.
Comment #14
plachI have #10 applied and I still managed to get the same exception reported in the OP by using
og_is_group()
in an access callback and passing it a string rather than a group ID. Of course the string should never pass access checks, but a 403 would be preferable rather than a WSOD :)The attached patch considers also this case.
Other than that, this looks great to me, thanks!
Comment #15
moritzz CreditAttribution: moritzz commentedI agree with #14, event though the patch did break current 2.1. I try again with dev later. Thanks for the fix!
Comment #16
dharizza CreditAttribution: dharizza commentedHello,
I've been having the same issue but directly on og_group, when the group was removed i could get to og_group and it tried to load the node for a gid which doesn't exist, generating an issue on entity_extract_ids. I'm uploading here a patch to cover that too.
Comment #17
izmeez CreditAttribution: izmeez commented@dharizza The patch in #16 looks like a further addition to the patch in comment #14. It would be better to combine them into one patch.
Comment #18
izmeez CreditAttribution: izmeez commentedThe patch in #14 has already been committed in the og git repository and og-7.x-2.x-dev (2019-05-09).
This leaves the patch in #16 as a new patch that does apply without difficulty and that needs review.
Comment #19
JasonSafro CreditAttribution: JasonSafro as a volunteer commented@dharizza Your patch looks more comprehensive. But, it seems to also change some of the variable names. I could see where this might cause issues further down in the function.