Browse Source

Merge pull request #11770 from MrPetovan/bug/notices

Handle rare case where contact doesn't exist in Model\Group::getIdsByContactId
pull/11702/merge
Michael Vogel 2 months ago committed by GitHub
parent
commit
f9777ce0dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/Model/Group.php

16
src/Model/Group.php

@ -138,25 +138,29 @@ class Group
*/
public static function getIdsByContactId(int $cid): array
{
$return = [];
$contact = Contact::getById($cid, ['rel']);
if (!$contact) {
return [];
}
$groupIds = [];
$stmt = DBA::select('group_member', ['gid'], ['contact-id' => $cid]);
while ($group = DBA::fetch($stmt)) {
$return[] = $group['gid'];
$groupIds[] = $group['gid'];
}
DBA::close($stmt);
// Meta-groups
$contact = Contact::getById($cid, ['rel']);
if ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND) {
$return[] = self::FOLLOWERS;
$groupIds[] = self::FOLLOWERS;
}
if ($contact['rel'] == Contact::FRIEND) {
$return[] = self::MUTUALS;
$groupIds[] = self::MUTUALS;
}
return $return;
return $groupIds;
}
/**

Loading…
Cancel
Save