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?
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 0001-Fixed-overzealous-caching.patch | 699 bytes | christopherreay |
| includes_tree.inc_og_subgroups_get_tree.fixTooMuchCaching.patch | 556 bytes | christopherreay |
Comments
Comment #1
christopherreay commentedComment #2
mstef commentedWhich 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?
Comment #3
bschilt commentedI 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.
Comment #4
christopherreay commentedI 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) {...}"
Comment #5
mstef commentedOh.. my mistake. I looked too quickly. Nice call..
Comment #6
christopherreay commentedHeres another patch that actually applies with git :)
Comment #7
bschilt commentedThanks for the patch. Committed.