[COMPONENT][Search] Fix searching for actors

This commit is contained in:
Hugo Sales 2021-12-08 21:25:48 +00:00
parent 139da2c07f
commit bc3e6ac704
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 12 additions and 8 deletions

View File

@ -47,11 +47,14 @@ class Search extends FeedController
$note_qb->select('note')->from('App\Entity\Note', 'note')->orderBy('note.created', 'DESC');
$actor_qb->select('actor')->from('App\Entity\Actor', 'actor')->orderBy('actor.created', 'DESC');
Event::handle('SearchQueryAddJoins', [&$note_qb, &$actor_qb]);
$notes = $actors = [];
if (!\is_null($note_criteria)) {
$note_qb->addCriteria($note_criteria);
$notes = $note_qb->getQuery()->execute();
} elseif (!\is_null($actor_criteria)) {
}
if (!\is_null($actor_criteria)) {
$actor_qb->addCriteria($actor_criteria);
$actors = $actor_qb->getQuery()->execute();
}

View File

@ -99,8 +99,8 @@ class Search extends Component
{
if (Formatting::startsWith($term, ['lang', 'language'])) {
$search_term = str_contains($term, ':') ? explode(':', $term)[1] : $term;
$note_expr = $eb->eq('language.locale', $search_term);
$actor_expr = $eb->eq('language.locale', $search_term);
$note_expr = $eb->startsWith('language.locale', $search_term);
$actor_expr = $eb->startsWith('language.locale', $search_term);
return Event::stop;
}
return Event::next;

View File

@ -80,12 +80,12 @@ abstract class Parser
$ret = Event::handle('SearchCreateExpression', [$eb, $term, $language, &$note_res, &$actor_res]);
if (\is_null($note_res) && \is_null($actor_res)) {
throw new ServerException("No one claimed responsibility for a match term: {$term}");
} elseif (!\is_null($note_res)) {
}
if (!\is_null($note_res)) {
$note_parts[] = $note_res;
} elseif (!\is_null($actor_res)) {
}
if (!\is_null($actor_res)) {
$actor_parts[] = $actor_res;
} else {
throw new ServerException('Unexpected state in Search parser');
}
$right = $left = $index + 1;
@ -109,7 +109,8 @@ abstract class Parser
if (!empty($note_parts)) {
self::connectParts($note_parts, $note_criteria_arr, $last_op, $eb, force: true);
$note_criteria = new Criteria($eb->orX(...$note_criteria_arr));
} elseif (!empty($actor_parts)) {
}
if (!empty($actor_parts)) {
self::connectParts($actor_parts, $actor_criteria_arr, $last_op, $eb, force: true);
$actor_criteria = new Criteria($eb->orX(...$actor_criteria_arr));
}