From 9c38b61e51a053f8aafe96bcc6b99291a1fe4bd3 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 9 Dec 2016 06:09:39 -0800 Subject: [PATCH] Fix an issue where tokenizers can sort milestone results into the wrong query phase Summary: Fixes T11955. Currently, milestones have an internal name of "Parent (Milestone) ...". This makes them look like they're prefix matches for "Parent", but they're actually prefix matches for "Milestone". Reorder the names so that the internal name is "Milestone Parent ...". Test Plan: Created a project "AAA" with milestone "BBB". Searched for "AAA", found "AAA" and milestone "AAA (BBB)". Reviewers: chad Reviewed By: chad Maniphest Tasks: T11955 Differential Revision: https://secure.phabricator.com/D17013 --- .../typeahead/PhabricatorProjectDatasource.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/applications/project/typeahead/PhabricatorProjectDatasource.php b/src/applications/project/typeahead/PhabricatorProjectDatasource.php index 90294f29fb..d0abcad2ca 100644 --- a/src/applications/project/typeahead/PhabricatorProjectDatasource.php +++ b/src/applications/project/typeahead/PhabricatorProjectDatasource.php @@ -102,10 +102,21 @@ final class PhabricatorProjectDatasource } $all_strings = array(); - $all_strings[] = $proj->getDisplayName(); + + // NOTE: We list the project's name first because results will be + // sorted into prefix vs content phases incorrectly if we don't: it + // will look like "Parent (Milestone)" matched "Parent" as a prefix, + // but it did not. + $all_strings[] = $proj->getName(); + + if ($proj->isMilestone()) { + $all_strings[] = $proj->getParentProject()->getName(); + } + foreach ($proj->getSlugs() as $project_slug) { $all_strings[] = $project_slug->getSlug(); } + $all_strings = implode("\n", $all_strings); $proj_result = id(new PhabricatorTypeaheadResult())