I had a group that showed in every user account in their My account. Without any valid reason. After looking into the code, I found that og_subgroups where adding this group has a result of fetching parents. BUT it's results where badly formatted : the array returned by og_subgroups_get_effective_groups should be indexed by the group ID ... That wasn't the case : I dumped the result of this function, and it gave an array with an entry indexed by the '' (empty string)... Which was my faulty group.
I found that the bug might be that "og_subgroups_get_effective_groups" was calling "og_subgroups_get_parents" and relied on the fact that it would return an array of nodes that would have a simple "nid" key/value... But there aren't any "nid" but a "group_nid".
So I simply changed the name "group_nid" to "nid" and all worked nicely.
function og_subgroups_get_parents($gid) {
$result = db_query('SELECT oga.group_nid as nid, n.title, n.type, n.status FROM {og_ancestry} oga INNER JOIN {node} n where oga.nid=%d AND oga.group_nid=n.nid', $gid);
$parents = array();
while ($row = db_fetch_array($result)) {
if (og_is_group_type($row['type'])) {
$parents[$row['nid']] = $row;
}
}
return $parents;
}
Could this bug be corrected in next versions ? Thanks !
Comments
Comment #1
ezra-g commentedThanks for investigating this. I believe this has to do with og_subgroups_get_effective_groups() being called by og_subgroups_user(), which is unnecessary since the module stores group membership in the same way as og.module. This may be resolved as a result of some changes a while back in the development version but I will leave the issue open until we can confirm. Are you still having this issue with the development version?
Comment #2
ezra-g commentedClosing...
Comment #3
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.