From fb4c95eb1c38bd4f1d19498bedf346d19c2e3726 Mon Sep 17 00:00:00 2001 From: Jacob Embree Date: Wed, 21 Feb 2018 07:55:12 -0500 Subject: [PATCH] Fix return value of og_get_groups_by_user() when $group_type is provided and results are empty --- og.module | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/og.module b/og.module index b798ea1b2..13112f1ed 100755 --- a/og.module +++ b/og.module @@ -3553,7 +3553,10 @@ function og_node_create_links($group_type, $gid, $field_name, $destination = NUL * types will be fetched. * * @return - * An array with the group IDs or an empty array. + * If $group_type is provided then an array of group IDs matching the + * specified group type. If $group_type is not provided then an associative + * array is returned containing arrays of group IDs keyed by group type. If + * no results are found an empty array is returned. */ function og_get_groups_by_user($account = NULL, $group_type = NULL) { if (empty($account)) { @@ -3581,12 +3584,10 @@ function og_get_groups_by_user($account = NULL, $group_type = NULL) { } } - if (empty($group_type)) { - return $gids; - } - elseif (!empty($gids[$group_type])) { - return $gids[$group_type]; + if (isset($group_type)) { + return isset($gids[$group_type]) ? $gids[$group_type] : array(); } + return $gids; } /** -- GitLab