Previously:

foreach ($wrapper->{$field_name . '__og_membership'}->value() as $og_membership) {
  $gids[] = $og_membership->gid;
}

Now:

$target_type = $field['settings']['target_type'];
$gids = og_get_entity_groups($entity_type, $entity, array(), $field_name);
$gids = !empty($gids[$target_type]) ? $gids[$target_type] : array();

As you can see, $gids used to be keyed by a simple numeric index, 0, 1, 2, etc. Now they're keyed by og_membership IDs. In most cases this is probably fine, but pathauto tokens seem to rely on the normal numeric index. That is, tokens in the format of [node:og-group-ref:0:...] no longer function.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexdmccabe’s picture

Status: Active » Needs review
FileSize
634 bytes

Here's a patch that should solve this issue.

brad.bulger’s picture

array_values() already produces a numerically ordered array. what's the purpose of the subsequent array_merge() call? i get it as a change to the original code line (that's still in 2.7)

$gids = !empty($gids[$target_type]) ? $gids[$target_type] : array();

but the current line (from 2.x-dev and the patch file here)

 $gids = !empty($gids[$target_type]) ? array_values($gids[$target_type]) : array();

should be sufficient on its own, no?