When user has no access to the taxonomy term, we get an error in og_get_user_roles() function:

EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7880 of /var/www/horizon/includes/common.inc).

OG relies on entity_load_single succeeding when it is not guaranteed to do so.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alan-ps created an issue. See original summary.

alan-ps’s picture

Status: Active » Needs review
FileSize
460 bytes

Should the user have roles in a group he doesn't have access to? To my mind - no, and we can fix it by adding a simple check. I've attached a patch for review.

mxr576’s picture

mxr576’s picture

Status: Needs review » Reviewed & tested by the community
mxr576’s picture

@alan-ps I think you should create a pull request on Github, because OG's development is happening there.

I've created an issue for this on Github as well: https://github.com/Gizra/og/issues/224

amitaibu’s picture

+++ b/og.module
@@ -2765,7 +2765,10 @@ function og_get_user_roles($group_type, $gid, $uid = NULL, $include = TRUE, $che
+  if (!$group = entity_load_single($group_type, $gid)) {

As an API function I don't think it needs to check for the correctness of the data we pass it.

One might argue, that instead of return, we should actually throw an Exception.

amitaibu’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

I'll won't fix it. If you feel strongly differently, please re-open with an explanation why.

marcelovani’s picture

Status: Closed (won't fix) » Needs review

EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7880 of /var/www/horizon/includes/common.inc).

That is the exception.

The reason we are getting this is because certain user belongs to groups that no longer exists.

I think this is a valid patch

claudfernandes’s picture

Issue tags: +Thanks @marcelovani, +it is great, +it has been buggy me for ages
claudfernandes’s picture

Issue tags: -Thanks @marcelovani, -it is great, -it has been buggy me for ages

Thanks @marcelovani, it is great, it has been buggy me for ages