diff --git a/components/Search/Controller/Search.php b/components/Search/Controller/Search.php index ec99d2015c..9d751cd7a1 100644 --- a/components/Search/Controller/Search.php +++ b/components/Search/Controller/Search.php @@ -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(); } diff --git a/components/Search/Search.php b/components/Search/Search.php index 0c862e1cf8..4c98d76fff 100644 --- a/components/Search/Search.php +++ b/components/Search/Search.php @@ -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; diff --git a/components/Search/Util/Parser.php b/components/Search/Util/Parser.php index d4c1f8446a..306f45edc6 100644 --- a/components/Search/Util/Parser.php +++ b/components/Search/Util/Parser.php @@ -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)); }