1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Fix fatal when searching for "r matey prepare to be boarded"

Summary:
See <https://discourse.phabricator-community.org/t/unrecoverable-fatal-error-on-repository-search-in-top-search-bar/503/2>.

The Ferret engine replaced `withNameContains()`, but I missed this obscure callsite.

Test Plan:
  - Searched for `r matey prepare to be boarded`.
  - Before: fatal.
  - After: no fatal.
  - Also searched for `r <actual repository name>`, got repository.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18661
This commit is contained in:
epriestley 2017-09-29 09:01:12 -07:00
parent b75a4151c8
commit a3a6c4ed2e

View file

@ -50,17 +50,35 @@ final class PhabricatorJumpNavHandler extends Phobject {
return id(new AphrontRedirectResponse())
->setURI("/diffusion/symbol/$symbol/?jump=true$context");
case 'find-repository':
$name = $matches[1];
$raw_query = $matches[1];
$engine = id(new PhabricatorRepository())
->newFerretEngine();
$compiler = id(new PhutilSearchQueryCompiler())
->setEnableFunctions(true);
$raw_tokens = $compiler->newTokens($raw_query);
$fulltext_tokens = array();
foreach ($raw_tokens as $raw_token) {
$fulltext_token = id(new PhabricatorFulltextToken())
->setToken($raw_token);
$fulltext_tokens[] = $fulltext_token;
}
$repositories = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->withNameContains($name)
->withFerretConstraint($engine, $fulltext_tokens)
->execute();
if (count($repositories) == 1) {
// Just one match, jump to repository.
$uri = head($repositories)->getURI();
} else {
// More than one match, jump to search.
$uri = urisprintf('/diffusion/?order=name&name=%s', $name);
$uri = urisprintf(
'/diffusion/?order=name&query=%s',
$raw_query);
}
return id(new AphrontRedirectResponse())->setURI($uri);
default: