Merge pull request #1565 from nextcloud/fix-0106-search

ignore exception on unknown account during search
pull/1572/head
Louis 2023-01-09 10:34:32 +01:00 zatwierdzone przez GitHub
commit c91aa1273b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 5 dodań i 8 usunięć

Wyświetl plik

@ -211,11 +211,11 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
*/ */
public function searchAccounts(string $search): array { public function searchAccounts(string $search): array {
$qb = $this->getCacheActorsSelectSql(); $qb = $this->getCacheActorsSelectSql();
$this->searchInAccount($qb, $search); $qb->searchInAccount($search);
/** @var SocialQueryBuilder $qb */ /** @var SocialQueryBuilder $qb */
$qb->leftJoinCacheDocuments('icon_id'); $qb->leftJoinCacheDocuments('icon_id');
$this->leftJoinDetails($qb); $this->leftJoinDetails($qb);
$this->limitResults($qb, 25); $qb->limitResults(25);
return $this->getCacheActorsFromRequest($qb); return $this->getCacheActorsFromRequest($qb);
} }

Wyświetl plik

@ -83,21 +83,18 @@ class SearchService {
* @return Person[] * @return Person[]
*/ */
public function searchAccounts(string $search): array { public function searchAccounts(string $search): array {
$result = [];
$type = $this->getTypeFromSearch($search); $type = $this->getTypeFromSearch($search);
if ($search === '' || !$type & self::SEARCH_ACCOUNTS) { if ($search === '' || !$type & self::SEARCH_ACCOUNTS) {
return $result; return [];
} }
if (substr($search, 0, 1) === '@') { $search = ltrim($search, '@');
$search = substr($search, 1);
}
try { try {
// search and cache eventual exact account first
$this->cacheActorService->getFromAccount($search); $this->cacheActorService->getFromAccount($search);
} catch (Exception $e) { } catch (Exception $e) {
$this->logger->notice('searchAccounts', ['exception' => $e, 'search' => $search]);
} }
return $this->cacheActorService->searchCachedAccounts($search); return $this->cacheActorService->searchCachedAccounts($search);