From 059860047615343eda765ebe9789c0ff51264c0d Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 7 Oct 2013 12:51:24 -0700 Subject: [PATCH] Always pass handles to tokenizers, not ` name>` maps Summary: Ref T1279. Prerequisite for adding icons or other type information to tokenizers, since we don't currently have enough information to prefill them when rendering things from the server side. By passing handles in, the tokenizer can extract type information. Test Plan: - Searched by user in Audit. - Sent Conpherence from profile page. - Tried to send an empty conpherence. - Searched Countdown by user. - Edited CCs in Differential. - Edited reviewers in Differential. - Edited a commit's projects. - Searched lint by owner. - Searched feed by owner/project. - Searched files by owner. - Searched Herald by owner. - Searched Legalpad by owner. - Searched Macro by owner. - Filtered Maniphest reports by project. - Edited CCs in Maniphest. - Searched Owners by owner. - Edited an Owners package. - Searched Paste by owner. - Searched activity logs by owner. - Searched for mocks by owner. - Edited a mock's CCs. - Searched Ponder by owner. - Searched projects by owner. - Edited a Releeph project's pushers. - Searched Releeph by requestor. - Edited "Uses Symbols" for an Arcanist project. - Edited all tokenizers in main search. - Searched Slowvote by user. Reviewers: chad, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1279 Differential Revision: https://secure.phabricator.com/D7248 --- .../PhabricatorAuditListController.php | 4 +--- .../controller/ConpherenceNewController.php | 16 +++++++++------- .../query/PhabricatorCountdownSearchEngine.php | 5 ++--- .../DifferentialCCsFieldSpecification.php | 2 +- .../DifferentialReviewersFieldSpecification.php | 2 +- .../controller/DiffusionCommitEditController.php | 2 +- .../controller/DiffusionLintController.php | 14 +++++--------- .../feed/query/PhabricatorFeedSearchEngine.php | 9 ++++----- .../files/query/PhabricatorFileSearchEngine.php | 5 ++--- .../herald/query/HeraldRuleSearchEngine.php | 5 ++--- .../query/LegalpadDocumentSearchEngine.php | 5 ++--- .../macro/query/PhabricatorMacroSearchEngine.php | 5 ++--- .../controller/ManiphestReportController.php | 8 ++------ .../controller/ManiphestTaskEditController.php | 10 +++------- .../PhabricatorOwnersEditController.php | 13 +++++-------- .../PhabricatorOwnersListController.php | 4 +--- .../paste/query/PhabricatorPasteSearchEngine.php | 5 ++--- .../PhabricatorPeopleLogsController.php | 8 ++------ .../controller/PholioMockEditController.php | 4 +--- .../pholio/query/PholioMockSearchEngine.php | 6 ++---- .../ponder/query/PonderQuestionSearchEngine.php | 8 ++------ .../query/PhabricatorProjectSearchEngine.php | 5 ++--- .../project/ReleephProjectEditController.php | 7 ++----- .../releeph/query/ReleephRequestSearchEngine.php | 5 ++--- ...orRepositoryArcanistProjectEditController.php | 8 ++++---- .../controller/PhabricatorSearchController.php | 4 ---- .../query/PhabricatorSlowvoteSearchEngine.php | 5 ++--- .../form/control/AphrontFormTokenizerControl.php | 11 ++--------- 28 files changed, 66 insertions(+), 119 deletions(-) diff --git a/src/applications/audit/controller/PhabricatorAuditListController.php b/src/applications/audit/controller/PhabricatorAuditListController.php index 41823d76a4..9933b1851a 100644 --- a/src/applications/audit/controller/PhabricatorAuditListController.php +++ b/src/applications/audit/controller/PhabricatorAuditListController.php @@ -139,9 +139,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController { $tok_value = null; if ($handle) { - $tok_value = array( - $handle->getPHID() => $handle->getFullName(), - ); + $tok_value = array($handle); } $form->appendChild( diff --git a/src/applications/conpherence/controller/ConpherenceNewController.php b/src/applications/conpherence/controller/ConpherenceNewController.php index 077ed2d222..b2a3cdd4a7 100644 --- a/src/applications/conpherence/controller/ConpherenceNewController.php +++ b/src/applications/conpherence/controller/ConpherenceNewController.php @@ -11,15 +11,12 @@ final class ConpherenceNewController extends ConpherenceController { $title = pht('New Message'); $participants = array(); + $participant_prefill = null; $message = ''; $e_participants = null; $e_message = null; // this comes from ajax requests from all over. should be a single phid. - $participant_prefill = $request->getStr('participant'); - if ($participant_prefill) { - $participants[] = $participant_prefill; - } if ($request->isFormPost()) { $participants = $request->getArr('participants'); @@ -47,15 +44,20 @@ final class ConpherenceNewController extends ConpherenceController { return id(new AphrontRedirectResponse()) ->setURI($uri); } + } else { + $participant_prefill = $request->getStr('participant'); + if ($participant_prefill) { + $participants[] = $participant_prefill; + } } + $participant_handles = array(); if ($participants) { - $handles = id(new PhabricatorHandleQuery()) + $participant_handles = id(new PhabricatorHandleQuery()) ->setViewer($user) ->withPHIDs($participants) ->execute(); - $participant_handles = mpull($handles, 'getFullName', 'getPHID'); } $submit_uri = $this->getApplicationURI('new/'); @@ -64,7 +66,7 @@ final class ConpherenceNewController extends ConpherenceController { // TODO - we can get a better cancel_uri once we get better at crazy // ajax jonx T2086 if ($participant_prefill) { - $handle = $handles[$participant_prefill]; + $handle = $participant_handles[$participant_prefill]; $cancel_uri = $handle->getURI(); } diff --git a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php index d5669522e4..ca843e2c2b 100644 --- a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php +++ b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php @@ -33,11 +33,10 @@ final class PhabricatorCountdownSearchEngine AphrontFormView $form, PhabricatorSavedQuery $saved_query) { $phids = $saved_query->getParameter('authorPHIDs', array()); - $handles = id(new PhabricatorHandleQuery()) + $author_handles = id(new PhabricatorHandleQuery()) ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $author_tokens = mpull($handles, 'getFullName', 'getPHID'); $upcoming = $saved_query->getParameter('upcoming'); @@ -47,7 +46,7 @@ final class PhabricatorCountdownSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('authors') ->setLabel(pht('Authors')) - ->setValue($author_tokens)) + ->setValue($author_handles)) ->appendChild( id(new AphrontFormCheckboxControl()) ->addCheckbox( diff --git a/src/applications/differential/field/specification/DifferentialCCsFieldSpecification.php b/src/applications/differential/field/specification/DifferentialCCsFieldSpecification.php index bfbf83e012..01e83e4846 100644 --- a/src/applications/differential/field/specification/DifferentialCCsFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialCCsFieldSpecification.php @@ -50,7 +50,7 @@ final class DifferentialCCsFieldSpecification public function renderEditControl() { $cc_map = array(); foreach ($this->ccs as $phid) { - $cc_map[$phid] = $this->getHandle($phid)->getFullName(); + $cc_map[] = $this->getHandle($phid); } return id(new AphrontFormTokenizerControl()) ->setLabel('CC') diff --git a/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php b/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php index b6d00ce7a8..b82267c7c2 100644 --- a/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php @@ -89,7 +89,7 @@ final class DifferentialReviewersFieldSpecification public function renderEditControl() { $reviewer_map = array(); foreach ($this->reviewers as $phid) { - $reviewer_map[$phid] = $this->getHandle($phid)->getFullName(); + $reviewer_map[] = $this->getHandle($phid); } return id(new AphrontFormTokenizerControl()) ->setLabel(pht('Reviewers')) diff --git a/src/applications/diffusion/controller/DiffusionCommitEditController.php b/src/applications/diffusion/controller/DiffusionCommitEditController.php index 06398d19e9..13e78ea1a0 100644 --- a/src/applications/diffusion/controller/DiffusionCommitEditController.php +++ b/src/applications/diffusion/controller/DiffusionCommitEditController.php @@ -27,7 +27,7 @@ final class DiffusionCommitEditController extends DiffusionController { $commit_phid, $edge_type); $handles = $this->loadViewerHandles($current_proj_phids); - $proj_t_values = mpull($handles, 'getFullName', 'getPHID'); + $proj_t_values = $handles; if ($request->isFormPost()) { $proj_phids = $request->getArr('projects'); diff --git a/src/applications/diffusion/controller/DiffusionLintController.php b/src/applications/diffusion/controller/DiffusionLintController.php index d7166047a5..881b26aeb5 100644 --- a/src/applications/diffusion/controller/DiffusionLintController.php +++ b/src/applications/diffusion/controller/DiffusionLintController.php @@ -21,18 +21,14 @@ final class DiffusionLintController extends DiffusionController { $owners = array(); if (!$drequest) { if (!$request->getArr('owner')) { - if ($user->isLoggedIn()) { - $owners[$user->getPHID()] = $user->getFullName(); - } + $owners = array($user->getPHID()); } else { - $phids = $request->getArr('owner'); - $phid = reset($phids); - $handles = $this->loadViewerHandles(array($phid)); - $owners[$phid] = $handles[$phid]->getFullName(); + $owners = array(head($request->getArr('owner'))); } + $owner_handles = $this->loadViewerHandles($owners); } - $codes = $this->loadLintCodes(array_keys($owners)); + $codes = $this->loadLintCodes($owners); if ($codes && !$drequest) { // TODO: Build some real Query classes for this stuff. @@ -125,7 +121,7 @@ final class DiffusionLintController extends DiffusionController { ->setLimit(1) ->setName('owner') ->setLabel(pht('Owner')) - ->setValue($owners)) + ->setValue($owner_handles)) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue('Filter')); diff --git a/src/applications/feed/query/PhabricatorFeedSearchEngine.php b/src/applications/feed/query/PhabricatorFeedSearchEngine.php index dfd626eb7c..c4048d7f53 100644 --- a/src/applications/feed/query/PhabricatorFeedSearchEngine.php +++ b/src/applications/feed/query/PhabricatorFeedSearchEngine.php @@ -66,9 +66,8 @@ final class PhabricatorFeedSearchEngine ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $tokens = mpull($handles, 'getFullName', 'getPHID'); - $user_tokens = array_select_keys($tokens, $user_phids); - $proj_tokens = array_select_keys($tokens, $proj_phids); + $user_handles = array_select_keys($handles, $user_phids); + $proj_handles = array_select_keys($handles, $proj_phids); $viewer_projects = $saved_query->getParameter('viewerProjects'); @@ -78,13 +77,13 @@ final class PhabricatorFeedSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('users') ->setLabel(pht('Include Users')) - ->setValue($user_tokens)) + ->setValue($user_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) ->setDatasource('/typeahead/common/projects/') ->setName('projectPHIDs') ->setLabel(pht('Include Projects')) - ->setValue($proj_tokens)) + ->setValue($proj_handles)) ->appendChild( id(new AphrontFormCheckboxControl()) ->addCheckbox( diff --git a/src/applications/files/query/PhabricatorFileSearchEngine.php b/src/applications/files/query/PhabricatorFileSearchEngine.php index 2281fa8fce..c16d816685 100644 --- a/src/applications/files/query/PhabricatorFileSearchEngine.php +++ b/src/applications/files/query/PhabricatorFileSearchEngine.php @@ -46,11 +46,10 @@ final class PhabricatorFileSearchEngine PhabricatorSavedQuery $saved_query) { $phids = $saved_query->getParameter('authorPHIDs', array()); - $handles = id(new PhabricatorHandleQuery()) + $author_handles = id(new PhabricatorHandleQuery()) ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $author_tokens = mpull($handles, 'getFullName', 'getPHID'); $explicit = $saved_query->getParameter('explicit'); @@ -60,7 +59,7 @@ final class PhabricatorFileSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('authors') ->setLabel(pht('Authors')) - ->setValue($author_tokens)) + ->setValue($author_handles)) ->appendChild( id(new AphrontFormCheckboxControl()) ->addCheckbox( diff --git a/src/applications/herald/query/HeraldRuleSearchEngine.php b/src/applications/herald/query/HeraldRuleSearchEngine.php index ccafc360d5..2e6f658bc3 100644 --- a/src/applications/herald/query/HeraldRuleSearchEngine.php +++ b/src/applications/herald/query/HeraldRuleSearchEngine.php @@ -52,11 +52,10 @@ final class HeraldRuleSearchEngine PhabricatorSavedQuery $saved_query) { $phids = $saved_query->getParameter('authorPHIDs', array()); - $handles = id(new PhabricatorHandleQuery()) + $author_handles = id(new PhabricatorHandleQuery()) ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $author_tokens = mpull($handles, 'getFullName', 'getPHID'); $content_type = $saved_query->getParameter('contentType'); $rule_type = $saved_query->getParameter('ruleType'); @@ -67,7 +66,7 @@ final class HeraldRuleSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('authors') ->setLabel(pht('Authors')) - ->setValue($author_tokens)) + ->setValue($author_handles)) ->appendChild( id(new AphrontFormSelectControl()) ->setName('contentType') diff --git a/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php b/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php index c510ec7765..5d11671ab9 100644 --- a/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php +++ b/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php @@ -53,7 +53,6 @@ final class LegalpadDocumentSearchEngine ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $tokens = mpull($handles, 'getFullName', 'getPHID'); $form ->appendChild( @@ -61,13 +60,13 @@ final class LegalpadDocumentSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('creators') ->setLabel(pht('Creators')) - ->setValue(array_select_keys($tokens, $creator_phids))) + ->setValue(array_select_keys($handles, $creator_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) ->setDatasource('/typeahead/common/users/') ->setName('contributors') ->setLabel(pht('Contributors')) - ->setValue(array_select_keys($tokens, $contributor_phids))); + ->setValue(array_select_keys($handles, $contributor_phids))); $this->buildDateRange( $form, diff --git a/src/applications/macro/query/PhabricatorMacroSearchEngine.php b/src/applications/macro/query/PhabricatorMacroSearchEngine.php index c980979c29..933f1fc2c7 100644 --- a/src/applications/macro/query/PhabricatorMacroSearchEngine.php +++ b/src/applications/macro/query/PhabricatorMacroSearchEngine.php @@ -66,11 +66,10 @@ final class PhabricatorMacroSearchEngine PhabricatorSavedQuery $saved_query) { $phids = $saved_query->getParameter('authorPHIDs', array()); - $handles = id(new PhabricatorHandleQuery()) + $author_handles = id(new PhabricatorHandleQuery()) ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $author_tokens = mpull($handles, 'getFullName', 'getPHID'); $status = $saved_query->getParameter('status'); $names = implode(', ', $saved_query->getParameter('names', array())); @@ -89,7 +88,7 @@ final class PhabricatorMacroSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('authors') ->setLabel(pht('Authors')) - ->setValue($author_tokens)) + ->setValue($author_handles)) ->appendChild( id(new AphrontFormTextControl()) ->setName('nameLike') diff --git a/src/applications/maniphest/controller/ManiphestReportController.php b/src/applications/maniphest/controller/ManiphestReportController.php index a86173c6a3..5b0979fd7f 100644 --- a/src/applications/maniphest/controller/ManiphestReportController.php +++ b/src/applications/maniphest/controller/ManiphestReportController.php @@ -265,9 +265,7 @@ final class ManiphestReportController extends ManiphestController { $tokens = array(); if ($handle) { - $tokens = array( - $handle->getPHID() => $handle->getFullName(), - ); + $tokens = array($handle); } $filter = $this->renderReportFilters($tokens, $has_window = false); @@ -635,9 +633,7 @@ final class ManiphestReportController extends ManiphestController { $tokens = array(); if ($project_handle) { - $tokens = array( - $project_handle->getPHID() => $project_handle->getFullName(), - ); + $tokens = array($project_handle); } $filter = $this->renderReportFilters($tokens, $has_window = true); diff --git a/src/applications/maniphest/controller/ManiphestTaskEditController.php b/src/applications/maniphest/controller/ManiphestTaskEditController.php index 95d904ff77..73a2445d6b 100644 --- a/src/applications/maniphest/controller/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditController.php @@ -343,8 +343,6 @@ final class ManiphestTaskEditController extends ManiphestController { $handles = $this->loadViewerHandles($phids); - $tvalues = mpull($handles, 'getFullName', 'getPHID'); - $error_view = null; if ($errors) { $error_view = new AphrontErrorView(); @@ -355,21 +353,19 @@ final class ManiphestTaskEditController extends ManiphestController { $priority_map = ManiphestTaskPriority::getTaskPriorityMap(); if ($task->getOwnerPHID()) { - $assigned_value = array( - $task->getOwnerPHID() => $handles[$task->getOwnerPHID()]->getFullName(), - ); + $assigned_value = array($handles[$task->getOwnerPHID()]); } else { $assigned_value = array(); } if ($task->getCCPHIDs()) { - $cc_value = array_select_keys($tvalues, $task->getCCPHIDs()); + $cc_value = array_select_keys($handles, $task->getCCPHIDs()); } else { $cc_value = array(); } if ($task->getProjectPHIDs()) { - $projects_value = array_select_keys($tvalues, $task->getProjectPHIDs()); + $projects_value = array_select_keys($handles, $task->getProjectPHIDs()); } else { $projects_value = array(); } diff --git a/src/applications/owners/controller/PhabricatorOwnersEditController.php b/src/applications/owners/controller/PhabricatorOwnersEditController.php index 33a1aabeb7..77c3f582b5 100644 --- a/src/applications/owners/controller/PhabricatorOwnersEditController.php +++ b/src/applications/owners/controller/PhabricatorOwnersEditController.php @@ -123,15 +123,12 @@ final class PhabricatorOwnersEditController $primary = $package->getPrimaryOwnerPHID(); if ($primary && isset($handles[$primary])) { - $token_primary_owner = array( - $primary => $handles[$primary]->getFullName(), - ); + $handle_primary_owner = array($handles[$primary]); } else { - $token_primary_owner = array(); + $handle_primary_owner = array(); } - $token_all_owners = array_select_keys($handles, $owners); - $token_all_owners = mpull($token_all_owners, 'getFullName'); + $handles_all_owners = array_select_keys($handles, $owners); if ($package->getID()) { $title = pht('Edit Package'); @@ -195,14 +192,14 @@ final class PhabricatorOwnersEditController ->setLabel(pht('Primary Owner')) ->setName('primary') ->setLimit(1) - ->setValue($token_primary_owner) + ->setValue($handle_primary_owner) ->setError($e_primary)) ->appendChild( id(new AphrontFormTokenizerControl()) ->setDatasource('/typeahead/common/usersorprojects/') ->setLabel(pht('Owners')) ->setName('owners') - ->setValue($token_all_owners)) + ->setValue($handles_all_owners)) ->appendChild( id(new AphrontFormSelectControl()) ->setName('auditing') diff --git a/src/applications/owners/controller/PhabricatorOwnersListController.php b/src/applications/owners/controller/PhabricatorOwnersListController.php index 0d6130a59c..14431faa9e 100644 --- a/src/applications/owners/controller/PhabricatorOwnersListController.php +++ b/src/applications/owners/controller/PhabricatorOwnersListController.php @@ -153,9 +153,7 @@ final class PhabricatorOwnersListController $phids = $request->getArr('owner'); $phid = reset($phids); $handles = $this->loadViewerHandles(array($phid)); - $owners_search_value = array( - $phid => $handles[$phid]->getFullName(), - ); + $owners_search_value = array($handles[$phid]); } $callsigns = array('' => pht('(Any Repository)')); diff --git a/src/applications/paste/query/PhabricatorPasteSearchEngine.php b/src/applications/paste/query/PhabricatorPasteSearchEngine.php index 4101458ee2..542931edb9 100644 --- a/src/applications/paste/query/PhabricatorPasteSearchEngine.php +++ b/src/applications/paste/query/PhabricatorPasteSearchEngine.php @@ -48,11 +48,10 @@ final class PhabricatorPasteSearchEngine AphrontFormView $form, PhabricatorSavedQuery $saved_query) { $phids = $saved_query->getParameter('authorPHIDs', array()); - $handles = id(new PhabricatorHandleQuery()) + $author_handles = id(new PhabricatorHandleQuery()) ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $author_tokens = mpull($handles, 'getFullName', 'getPHID'); $languages = $saved_query->getParameter('languages', array()); $no_language = false; @@ -70,7 +69,7 @@ final class PhabricatorPasteSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('authors') ->setLabel(pht('Authors')) - ->setValue($author_tokens)) + ->setValue($author_handles)) ->appendChild( id(new AphrontFormTextControl()) ->setName('languages') diff --git a/src/applications/people/controller/PhabricatorPeopleLogsController.php b/src/applications/people/controller/PhabricatorPeopleLogsController.php index 9776e862e4..f43be11c23 100644 --- a/src/applications/people/controller/PhabricatorPeopleLogsController.php +++ b/src/applications/people/controller/PhabricatorPeopleLogsController.php @@ -22,16 +22,12 @@ final class PhabricatorPeopleLogsController $handles = $this->loadViewerHandles($phids); if ($filter_user) { $filter_user = reset($filter_user); - $user_value = array( - $filter_user => $handles[$filter_user]->getFullName(), - ); + $user_value = array($handles[$filter_user]); } if ($filter_actor) { $filter_actor = reset($filter_actor); - $actor_value = array( - $filter_actor => $handles[$filter_actor]->getFullName(), - ); + $actor_value = array($handles[$filter_actor]); } } diff --git a/src/applications/pholio/controller/PholioMockEditController.php b/src/applications/pholio/controller/PholioMockEditController.php index e27c0d9e70..a3dde9a4b8 100644 --- a/src/applications/pholio/controller/PholioMockEditController.php +++ b/src/applications/pholio/controller/PholioMockEditController.php @@ -230,8 +230,6 @@ final class PholioMockEditController extends PholioController { ->withPHIDs($v_cc) ->execute(); - $cc_tokens = mpull($handles, 'getFullName', 'getPHID'); - $image_elements = array(); foreach ($mock_images as $mock_image) { $image_elements[] = id(new PholioUploadedImageView()) @@ -303,7 +301,7 @@ final class PholioMockEditController extends PholioController { id(new AphrontFormTokenizerControl()) ->setLabel(pht('CC')) ->setName('cc') - ->setValue($cc_tokens) + ->setValue($handles) ->setUser($user) ->setDatasource('/typeahead/common/mailable/')) ->appendChild( diff --git a/src/applications/pholio/query/PholioMockSearchEngine.php b/src/applications/pholio/query/PholioMockSearchEngine.php index e64a44ef86..5da9d405ad 100644 --- a/src/applications/pholio/query/PholioMockSearchEngine.php +++ b/src/applications/pholio/query/PholioMockSearchEngine.php @@ -27,11 +27,10 @@ final class PholioMockSearchEngine PhabricatorSavedQuery $saved_query) { $phids = $saved_query->getParameter('authorPHIDs', array()); - $handles = id(new PhabricatorHandleQuery()) + $author_handles = id(new PhabricatorHandleQuery()) ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $author_tokens = mpull($handles, 'getFullName', 'getPHID'); $form ->appendChild( @@ -39,8 +38,7 @@ final class PholioMockSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('authors') ->setLabel(pht('Authors')) - ->setValue($author_tokens)); - + ->setValue($author_handles)); } protected function getURI($path) { diff --git a/src/applications/ponder/query/PonderQuestionSearchEngine.php b/src/applications/ponder/query/PonderQuestionSearchEngine.php index 57c3faaba0..ec715b028a 100644 --- a/src/applications/ponder/query/PonderQuestionSearchEngine.php +++ b/src/applications/ponder/query/PonderQuestionSearchEngine.php @@ -61,10 +61,6 @@ final class PonderQuestionSearchEngine ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $tokens = mpull($handles, 'getFullName', 'getPHID'); - - $author_tokens = array_select_keys($tokens, $author_phids); - $answerer_tokens = array_select_keys($tokens, $answerer_phids); $form ->appendChild( @@ -72,13 +68,13 @@ final class PonderQuestionSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('authors') ->setLabel(pht('Authors')) - ->setValue($author_tokens)) + ->setValue(array_select_keys($handles, $author_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) ->setDatasource('/typeahead/common/users/') ->setName('answerers') ->setLabel(pht('Answered By')) - ->setValue($answerer_tokens)) + ->setValue(array_select_keys($handles, $answerer_phids))) ->appendChild( id(new AphrontFormSelectControl()) ->setLabel(pht('Status')) diff --git a/src/applications/project/query/PhabricatorProjectSearchEngine.php b/src/applications/project/query/PhabricatorProjectSearchEngine.php index 448627ecf0..f10129bb29 100644 --- a/src/applications/project/query/PhabricatorProjectSearchEngine.php +++ b/src/applications/project/query/PhabricatorProjectSearchEngine.php @@ -36,11 +36,10 @@ final class PhabricatorProjectSearchEngine PhabricatorSavedQuery $saved_query) { $phids = $saved_query->getParameter('memberPHIDs', array()); - $handles = id(new PhabricatorHandleQuery()) + $member_handles = id(new PhabricatorHandleQuery()) ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $member_tokens = mpull($handles, 'getFullName', 'getPHID'); $status = $saved_query->getParameter('status'); @@ -50,7 +49,7 @@ final class PhabricatorProjectSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('members') ->setLabel(pht('Members')) - ->setValue($member_tokens)) + ->setValue($member_handles)) ->appendChild( id(new AphrontFormSelectControl()) ->setLabel(pht('Status')) diff --git a/src/applications/releeph/controller/project/ReleephProjectEditController.php b/src/applications/releeph/controller/project/ReleephProjectEditController.php index d39c6fcb52..47a42f46ea 100644 --- a/src/applications/releeph/controller/project/ReleephProjectEditController.php +++ b/src/applications/releeph/controller/project/ReleephProjectEditController.php @@ -135,10 +135,7 @@ final class ReleephProjectEditController extends ReleephProjectController { ->withPHIDs($pusher_phids) ->execute(); - $pusher_tokens = array(); - foreach ($pusher_phids as $phid) { - $pusher_tokens[$phid] = $handles[$phid]->getFullName(); - } + $pusher_handles = array_select_keys($handles, $pusher_phids); $basic_inset = id(new AphrontFormInsetView()) ->setTitle(pht('Basics')) @@ -209,7 +206,7 @@ final class ReleephProjectEditController extends ReleephProjectController { ->setLabel(pht('Pushers')) ->setName('pushers') ->setDatasource('/typeahead/common/users/') - ->setValue($pusher_tokens)); + ->setValue($pusher_handles)); $commit_author_inset = $this->buildCommitAuthorInset($commit_author); diff --git a/src/applications/releeph/query/ReleephRequestSearchEngine.php b/src/applications/releeph/query/ReleephRequestSearchEngine.php index cc38899a8c..53db39f630 100644 --- a/src/applications/releeph/query/ReleephRequestSearchEngine.php +++ b/src/applications/releeph/query/ReleephRequestSearchEngine.php @@ -60,11 +60,10 @@ final class ReleephRequestSearchEngine PhabricatorSavedQuery $saved_query) { $phids = $saved_query->getParameter('requestorPHIDs', array()); - $handles = id(new PhabricatorHandleQuery()) + $requestor_handles = id(new PhabricatorHandleQuery()) ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $requestor_tokens = mpull($handles, 'getFullName', 'getPHID'); $form ->appendChild( @@ -84,7 +83,7 @@ final class ReleephRequestSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('requestors') ->setLabel(pht('Requestors')) - ->setValue($requestor_tokens)); + ->setValue($requestor_handles)); } protected function getURI($path) { diff --git a/src/applications/repository/controller/PhabricatorRepositoryArcanistProjectEditController.php b/src/applications/repository/controller/PhabricatorRepositoryArcanistProjectEditController.php index 15a0b6f970..2330177d42 100644 --- a/src/applications/repository/controller/PhabricatorRepositoryArcanistProjectEditController.php +++ b/src/applications/repository/controller/PhabricatorRepositoryArcanistProjectEditController.php @@ -59,10 +59,10 @@ final class PhabricatorRepositoryArcanistProjectEditController } if ($project->getSymbolIndexProjects()) { - $uses = id(new PhabricatorRepositoryArcanistProject())->loadAllWhere( - 'phid in (%Ls)', - $project->getSymbolIndexProjects()); - $uses = mpull($uses, 'getName', 'getPHID'); + $uses = id(new PhabricatorHandleQuery()) + ->setViewer($user) + ->withPHIDs($project->getSymbolIndexProjects()) + ->execute(); } else { $uses = array(); } diff --git a/src/applications/search/controller/PhabricatorSearchController.php b/src/applications/search/controller/PhabricatorSearchController.php index 79f566a128..f9296b8a7b 100644 --- a/src/applications/search/controller/PhabricatorSearchController.php +++ b/src/applications/search/controller/PhabricatorSearchController.php @@ -128,22 +128,18 @@ final class PhabricatorSearchController $author_value = array_select_keys( $handles, $query->getParameter('author', array())); - $author_value = mpull($author_value, 'getFullName', 'getPHID'); $owner_value = array_select_keys( $handles, $query->getParameter('owner', array())); - $owner_value = mpull($owner_value, 'getFullName', 'getPHID'); $subscribers_value = array_select_keys( $handles, $query->getParameter('subscribers', array())); - $subscribers_value = mpull($subscribers_value, 'getFullName', 'getPHID'); $project_value = array_select_keys( $handles, $query->getParameter('project', array())); - $project_value = mpull($project_value, 'getFullName', 'getPHID'); $search_form = new AphrontFormView(); $search_form diff --git a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php index 39bac60ae2..f3693962f6 100644 --- a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php +++ b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php @@ -29,11 +29,10 @@ final class PhabricatorSlowvoteSearchEngine AphrontFormView $form, PhabricatorSavedQuery $saved_query) { $phids = $saved_query->getParameter('authorPHIDs', array()); - $handles = id(new PhabricatorHandleQuery()) + $author_handles = id(new PhabricatorHandleQuery()) ->setViewer($this->requireViewer()) ->withPHIDs($phids) ->execute(); - $author_tokens = mpull($handles, 'getFullName', 'getPHID'); $voted = $saved_query->getParameter('voted', false); @@ -43,7 +42,7 @@ final class PhabricatorSlowvoteSearchEngine ->setDatasource('/typeahead/common/users/') ->setName('authors') ->setLabel(pht('Authors')) - ->setValue($author_tokens)) + ->setValue($author_handles)) ->appendChild( id(new AphrontFormCheckboxControl()) ->addCheckbox( diff --git a/src/view/form/control/AphrontFormTokenizerControl.php b/src/view/form/control/AphrontFormTokenizerControl.php index c9a56f96c4..bf1773ef28 100644 --- a/src/view/form/control/AphrontFormTokenizerControl.php +++ b/src/view/form/control/AphrontFormTokenizerControl.php @@ -35,15 +35,8 @@ final class AphrontFormTokenizerControl extends AphrontFormControl { $name = $this->getName(); $values = nonempty($this->getValue(), array()); - // TODO: Convert tokenizers to always take raw handles. For now, we - // accept either a list of handles or a `map`. - try { - assert_instances_of($values, 'PhabricatorObjectHandle'); - $values = mpull($values, 'getFullName', 'getPHID'); - } catch (InvalidArgumentException $ex) { - // Ignore this, just use the values as provided. - } - + assert_instances_of($values, 'PhabricatorObjectHandle'); + $values = mpull($values, 'getFullName', 'getPHID'); if ($this->getID()) { $id = $this->getID();