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?

AttachmentSize
og_presave_do_not_filter_out_groups.patch496 bytes

#1

moshe weitzman - March 16, 2009 - 17:27
Status:needs review» needs work

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

Amitaibu - March 17, 2009 - 09:19
Status:needs work» needs review

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.

AttachmentSize
362493_2_og_presave_do_not_filter_out_groups.patch 898 bytes

#3

moshe weitzman - March 17, 2009 - 12:40

Needs testing with all the various forms of audience (checkboxes, select, optgroup, ...)

#4

cglusky - March 19, 2009 - 20:30

this would also fix this open issue #136606: Mailhandler cannot assign emailed content to group with mailhandler.

thanks,
coby

#5

moshe weitzman - April 7, 2009 - 19:06
Status:needs review» needs work

needs testing (ideally unit tests).

#6

Amitaibu - April 7, 2009 - 19:20
Status:needs work» won't fix

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

gdoteof - April 23, 2009 - 22:46

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

#9

crea - September 5, 2009 - 23:10
Version:HEAD» 6.x-2.x-dev
Status:won't fix» active

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

Campsoupster - October 25, 2009 - 00:32

subscribing.

#11

corona ronin - October 27, 2009 - 16:42

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

greg.harvey - November 5, 2009 - 13:22
Status:active» needs work

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

-morbiD- - November 26, 2009 - 17:01

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.

 
 

Drupal is a registered trademark of Dries Buytaert.