Skip to content

Commit

Permalink
Stop discovery when an addressbook home is discovered first
Browse files Browse the repository at this point in the history
- If there are no addressbooks under the addressbook home, this is fine
  and we return an empty list.
- If we do not manage to discover an addressbook home, throw an
  exception as would be expected by the function specification instead
  of an empty array.
  • Loading branch information
mstilkerich committed Aug 3, 2022
1 parent 098ce0a commit d6b736b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Services/Discovery.php
Expand Up @@ -132,9 +132,9 @@ public function discoverAddressbooks(Account $account): array
}
}

if (count($addressbooks) > 0) {
break 2;
}
// We found a valid addressbook home. If it contains no addressbooks, this is fine and the
// result of the discovery is an empty set.
return $addressbooks;
} catch (\Exception $e) {
Config::$logger->info("Exception while querying addressbooks: " . $e->getMessage());
}
Expand All @@ -143,7 +143,7 @@ public function discoverAddressbooks(Account $account): array
}
}

return $addressbooks;
throw new \Exception("Could not determine the addressbook home");
}

/**
Expand Down

0 comments on commit d6b736b

Please sign in to comment.