Problem/Motivation

The addition of a groups which are based on users instead of nodes caused an error in the logic for the commons_wikis "update any wiki content" override. The error occurs when an anonymous visitor or authenticated user who is not an administrator views almost any content. You'll see one error message on the default event page and four for the example wiki post.

Specifically, the error message states:

Notice: Undefined property: stdClass::$nid in commons_wikis_og_user_access_alter() (line 87 of .../profiles/commons/modules/contrib/commons_wikis/commons_wikis.module).

Line 87 of commons_wikis.module:

  $user_is_member = (bool) og_is_member('node', $context['group']->nid, 'user', $context['account']);

Specifically we have two issues

  1. Multiple messages due to og_is_member() in commons_wikis_og_user_access_alter() running for every possible user access combination rather than simply "update any wiki content".
  2. The new "user groups" aren't nodes but users, we we have no nid. We need separate logic for these.

Proposed resolution

We can solve the first issue by testing for "update any wiki content". The second part is a bit dirtier (at least with my coding skills, but we should be able to test for $content['group_type'] and react appropriately.

Comments

stupiddingo’s picture

Assigned: stupiddingo » Unassigned
Status: Active » Needs review
Issue tags: -Promised patch
StatusFileSize
new1.85 KB

Patch works in my testing, but I'm not saying it's elegant. Definitely needs review.

devin carlson’s picture

Priority: Normal » Major
Issue tags: +Commons 7.x-3.3 radar

I've seen this enough that I think that it's definitely something that has to be addressed before the 3.3 release.

japerry’s picture

Version: » 7.x-3.2
Status: Needs review » Reviewed & tested by the community

Agreed. that patch looks good to me, checks to make sure they are a member and that the group isn't private. Awesome :-)

japerry’s picture

Status: Reviewed & tested by the community » Fixed

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