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
- 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".
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | wikis_nid_does_not_exist-2013433-1.patch | 1.85 KB | stupiddingo |
Comments
Comment #1
stupiddingo commentedPatch works in my testing, but I'm not saying it's elegant. Definitely needs review.
Comment #2
devin carlson commentedI've seen this enough that I think that it's definitely something that has to be addressed before the 3.3 release.
Comment #3
japerryAgreed. that patch looks good to me, checks to make sure they are a member and that the group isn't private. Awesome :-)
Comment #4
devin carlson commentedMarked #2019569: [SOLVED] Notice: Undefined property: stdClass::$nid in commons_groups_og_user_access_alter() as a duplicate.
Comment #5
japerryFixed!
http://drupalcode.org/project/commons_wikis.git/commit/c2147df