From a3a6c4ed2edfa835c1e071f8a433380f2dfe0941 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 29 Sep 2017 09:01:12 -0700 Subject: [PATCH] Fix fatal when searching for "r matey prepare to be boarded" Summary: See . 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 `, got repository. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D18661 --- .../engine/PhabricatorJumpNavHandler.php | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/applications/search/engine/PhabricatorJumpNavHandler.php b/src/applications/search/engine/PhabricatorJumpNavHandler.php index 6f6ea3d0a9..ddade36d84 100644 --- a/src/applications/search/engine/PhabricatorJumpNavHandler.php +++ b/src/applications/search/engine/PhabricatorJumpNavHandler.php @@ -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: