og_nodeapi presave might filter out groups.
Amitaibu - January 22, 2009 - 10:03
| Project: | Organic groups |
| Version: | 6.x-2.x-dev |
| Component: | og.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Amitaibu |
| Status: | needs work |
Description
after
$node->og_groups = array_keys($node->og_groups);
$node->og_groups[176] = 176
Becomes $node->og_groups[0] = 176 which later might be array_filter() if node is re-saved.
Patch fixes it. However, I've noticed that og_groups value is already correct - maybe this line is redundant?
| Attachment | Size |
|---|---|
| og_presave_do_not_filter_out_groups.patch | 496 bytes |

#1
Yeah, the code needs to be studied here. We might be able to simplify. I would rather understand this fully than commit a bandaid.
#2
It seems that removing this line is enough. We keep the og_groups array as array($gid => $gid).
Also further down in og_save_ancestry() we can remove
$node->og_groups = array_unique($node->og_groups);as the array is keyed by the group id.#3
Needs testing with all the various forms of audience (checkboxes, select, optgroup, ...)
#4
this would also fix this open issue #136606: Mailhandler cannot assign emailed content to group with mailhandler.
thanks,
coby
#5
needs testing (ideally unit tests).
#6
I think it should be fixed in the #421888: Clean og_form_add_og_audience() and make it an API function patch, so setting to won't fix.
#7
for what its worth, this is happening in 6.x-1.3
The patch in #421888: Clean og_form_add_og_audience() and make it an API function did not solve my problem, but the patch in #2 above did fix the problem
#8
Can confirm the patch in #2 fixed #493940: 'event_node_update' rule breaks Organic Groups' ability to save groups a node is in (because of og_nodeapi presave issue?) for me. =)
#9
So what do we have now - 5 months later #421888: Clean og_form_add_og_audience() and make it an API function is still not finished as it seems, and this issue is closed. Maybe don't close bugs if you don't intend to fix them ? :)
My report: I had problem with Rules action not working on newly created group - apparently because of this bug. I applied changes from patch from #2 and it fixed my problem. Patch itself doesn't apply now but to reroll it against 2.x dev would be easy.
I would say, lets commit this as there are several people already reporting success here. And if Amitaibu decides to finish #421888: Clean og_form_add_og_audience() and make it an API function he can make patch which takes this patch into account. But in the meantime, users won't suffer from this bug.
#10
subscribing.
#11
Has this issue been addressed yet and committed to the new release? I think it might be related to another issue I've had with setting titles with rules, as I was directed to this issue via the rules queue: http://drupal.org/node/428498
My issue setting rules title is here:
http://drupal.org/node/610260
#12
See #5 - moshe says unit tests need to be provided for this to go in. Setting to "needs work" again. The patch seems to be RTBC, but without the tests it won't be committed.
#13
Just to point out, this patch breaks subdomain.module.
As far as I can tell, for group posts, subdomain.module builds the [subdomain] token by querying {node} with the value of $node->og_groups[0] but that key no longer gets created if this patch is applied.
Should I report this under subdomain.module issues? I guess it's their problem technically, but it doesn't actually exist yet because this patch hasn't been committed.