From 727a7de75941f756186ec7a3058c26a0a03eab9e Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 26 May 2016 10:01:44 -0700 Subject: [PATCH] Sort project typeahead tokens by display name, not hashtag Summary: Fixes T8510. Results are internally ordered by "name", which is the full list of strings a user can type to match a result. On the balance, it is probably good/correct to order by this (particularly, it allows `function(x)` to sort near `x`). However, the way projects were built put the tags first, so a project like "Discovery" could end up last if it had originally been created with a different name like "Search Team", so that its first slug is "search-team". Instead, put the display name first in the ordering. Test Plan: {F1661775} To reproduce in particular: - Create a project named "Zebra". - Create a lot of projects named "Armadillo-blahblahblah". - Rename "Zebra" to "Armadillo". Before the patch, the new "Armadillo" project would still sort as though it were named "Zebra". After the patch, it sorts as expected normally. Reviewers: chad Reviewed By: chad Maniphest Tasks: T8510 Differential Revision: https://secure.phabricator.com/D15981 --- .../project/typeahead/PhabricatorProjectDatasource.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/applications/project/typeahead/PhabricatorProjectDatasource.php b/src/applications/project/typeahead/PhabricatorProjectDatasource.php index 40d8dbb0e6..b51c55ee0a 100644 --- a/src/applications/project/typeahead/PhabricatorProjectDatasource.php +++ b/src/applications/project/typeahead/PhabricatorProjectDatasource.php @@ -82,8 +82,11 @@ final class PhabricatorProjectDatasource $closed = pht('Archived'); } - $all_strings = mpull($proj->getSlugs(), 'getSlug'); + $all_strings = array(); $all_strings[] = $proj->getDisplayName(); + foreach ($proj->getSlugs() as $project_slug) { + $all_strings[] = $project_slug->getSlug(); + } $all_strings = implode(' ', $all_strings); $proj_result = id(new PhabricatorTypeaheadResult())