This becomes a problem with, for example, changing the parent of a group node. Upon save, if, "node_access_records" performs behaviour dependent on the node_tree, calls to "node_subgroups_get_tree(TRUE) dont cause a new tree to be built.
Eventually a new tree IS built, but not until after the node_access_records (which is strange because node_access_records the the absolutely LAST call on the update function.

This can be fixed by a simple modification to
includes/tree.inc/og_subgroups_get_tree($reset = FALSE)
{ //Currently the tree is NOT rebuilt IF:
$reset is True
AND
the static variable $tree already contains stuff

Clearly, the meaning of $reset, is that the tree is rebuilt regardless of whether it has been built already.
I have made a simple change to a single conditional to fix this:
//From if (!$tree)... to ...
if ($reset || !$tree) {
$tree = _og_subgroups_get_tree();

// Cache this tree in the database
cache_set($cache_key, $tree);
}
}

Ive included a patch

Ive made some modifications to OG to integrate better with potential og subgroups development, and am working on some powerful tools for OG_subgroups usage.

Hope I can be of help further and maybe contribute to this project more?

Comments

christopherreay’s picture

Issue tags: ++patch
mstef’s picture

Priority: Major » Normal
Status: Active » Closed (works as designed)

Which version are you looking at?

http://drupalcode.org/project/og_subgroups.git/blob/dc83134c2efb7e0263a2...

Looks like this is taken care of already..

Am I wrong?

bschilt’s picture

Status: Closed (works as designed) » Needs review

I think christopherreay is correct with his patch. Line 33 will only generate a new tree from the db if $tree is false. I haven't tested the current function to be sure but looking at the logic in the function, I believe line 33 would need to check if $reset is true also.

christopherreay’s picture

I downloaded the latest version from git about 20 minutes before I submitted the patch, in order to create the patch using git.
The usecase is when nodeaccess that is based on the subgroup tree is calculated at the end of a node submit (for example, when changing the parent of a node). It is necessary for the nodeacess node records call to look at the new tree, and the tree is not rebuilt "yet".

The link that mikestefff provided, indeed bschilt, shows that line 33 ignores the value set on "$reset" when deciding whether or not to rebuild the tree, as the conditional is "if (!$tree) {...}"

mstef’s picture

Oh.. my mistake. I looked too quickly. Nice call..

christopherreay’s picture

StatusFileSize
new699 bytes

Heres another patch that actually applies with git :)

bschilt’s picture

Status: Needs review » Fixed

Thanks for the patch. Committed.

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