Problem: if somebody visits http://example.com/node/123invalid then the menu item for $entity_type/%/group is triggered, which has og_ui_get_group_admin() as access callback. That function receives the user supplied identifier from the menu system (in the example this would be "123invalid") and passes it on to further API functions without validation. This then results in an EntityMetadataWrapperException down the line.

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 736 of entity/includes/entity.wrapper.inc).

Solution: either og_ui_get_group_admin() validates the identifier or we use an explicit access callback function that wraps og_ui_get_group_admin() and returns proper TRUE/FALSE values.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

klausi’s picture

Status: Active » Needs review
FileSize
635 bytes

Patch attached.

TODO: test case.

amitaibu’s picture

> TODO: test case.

Are you going to provide one? :)

klausi’s picture

Sure, as the test case is so easy for this one :-)
Not sure if that test class is the right place to put it, but I leave that to your judgment.

shushu’s picture

Status: Needs review » Needs work

I didn't get too much into the reason, but this patch has a strange effect.
Let's say I have a node 1 which is a group. without the patch going to http://localhost/node/1junk would have cause the ugly error message we want to avoid, but with the patch we actually get the node, as if we were using http://localhost/node/1.
What I was expecting, and should happen, is that we will just get 403.

klausi’s picture

Status: Needs work » Needs review

That is expected core behavior, even without OG.

shushu’s picture

Status: Needs review » Reviewed & tested by the community

Good to know. Didn't expected that.

amitaibu’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks.

  • Commit 9cd494e on 7.x-2.x authored by klausi, committed by Amitaibu:
    Issue #2242237 by klausi: EntityMetadataWrapperException when OG UI uses...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.