Function og_abt_flatten_groups() mangles arrays

rwohleb - September 1, 2009 - 02:09
Project:OG Audience By Type
Version:6.x-1.0-rc1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

In the og_abt_flatten_groups() function, there are two places where it does an array_merge, instead of a straight concatenation. This has the effect of reindexing the array keys since the arrays have numeric keys. This is an issue because OG can normalize $node->og_groups by only using the array keys and ignoring the values. This will result in the post potentially being added to the wrong groups.

This:
$nids = array_merge($nids, $found);
Should be this:
$nids = $nids + $found;

and...

This:
$nids = array_merge($node->og_groups, $nids);
Should be this:
$nids = $node->og_groups + $nids;

 
 

Drupal is a registered trademark of Dries Buytaert.