Skip to content

Commit 0598600

Browse files
author
epriestley
committed
Always pass handles to tokenizers, not <phid -> 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
1 parent 2abbd51 commit 0598600

28 files changed

+66
-119
lines changed

src/applications/audit/controller/PhabricatorAuditListController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ private function buildListFilters(PhabricatorObjectHandle $handle = null) {
139139

140140
$tok_value = null;
141141
if ($handle) {
142-
$tok_value = array(
143-
$handle->getPHID() => $handle->getFullName(),
144-
);
142+
$tok_value = array($handle);
145143
}
146144

147145
$form->appendChild(

src/applications/conpherence/controller/ConpherenceNewController.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ public function processRequest() {
1111

1212
$title = pht('New Message');
1313
$participants = array();
14+
$participant_prefill = null;
1415
$message = '';
1516
$e_participants = null;
1617
$e_message = null;
1718

1819
// this comes from ajax requests from all over. should be a single phid.
19-
$participant_prefill = $request->getStr('participant');
20-
if ($participant_prefill) {
21-
$participants[] = $participant_prefill;
22-
}
2320

2421
if ($request->isFormPost()) {
2522
$participants = $request->getArr('participants');
@@ -47,15 +44,20 @@ public function processRequest() {
4744
return id(new AphrontRedirectResponse())
4845
->setURI($uri);
4946
}
47+
} else {
48+
$participant_prefill = $request->getStr('participant');
49+
if ($participant_prefill) {
50+
$participants[] = $participant_prefill;
51+
}
5052
}
5153

54+
5255
$participant_handles = array();
5356
if ($participants) {
54-
$handles = id(new PhabricatorHandleQuery())
57+
$participant_handles = id(new PhabricatorHandleQuery())
5558
->setViewer($user)
5659
->withPHIDs($participants)
5760
->execute();
58-
$participant_handles = mpull($handles, 'getFullName', 'getPHID');
5961
}
6062

6163
$submit_uri = $this->getApplicationURI('new/');
@@ -64,7 +66,7 @@ public function processRequest() {
6466
// TODO - we can get a better cancel_uri once we get better at crazy
6567
// ajax jonx T2086
6668
if ($participant_prefill) {
67-
$handle = $handles[$participant_prefill];
69+
$handle = $participant_handles[$participant_prefill];
6870
$cancel_uri = $handle->getURI();
6971
}
7072

src/applications/countdown/query/PhabricatorCountdownSearchEngine.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ public function buildSearchForm(
3333
AphrontFormView $form,
3434
PhabricatorSavedQuery $saved_query) {
3535
$phids = $saved_query->getParameter('authorPHIDs', array());
36-
$handles = id(new PhabricatorHandleQuery())
36+
$author_handles = id(new PhabricatorHandleQuery())
3737
->setViewer($this->requireViewer())
3838
->withPHIDs($phids)
3939
->execute();
40-
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
4140

4241
$upcoming = $saved_query->getParameter('upcoming');
4342

@@ -47,7 +46,7 @@ public function buildSearchForm(
4746
->setDatasource('/typeahead/common/users/')
4847
->setName('authors')
4948
->setLabel(pht('Authors'))
50-
->setValue($author_tokens))
49+
->setValue($author_handles))
5150
->appendChild(
5251
id(new AphrontFormCheckboxControl())
5352
->addCheckbox(

src/applications/differential/field/specification/DifferentialCCsFieldSpecification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function setValueFromRequest(AphrontRequest $request) {
5050
public function renderEditControl() {
5151
$cc_map = array();
5252
foreach ($this->ccs as $phid) {
53-
$cc_map[$phid] = $this->getHandle($phid)->getFullName();
53+
$cc_map[] = $this->getHandle($phid);
5454
}
5555
return id(new AphrontFormTokenizerControl())
5656
->setLabel('CC')

src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function validateField() {
8989
public function renderEditControl() {
9090
$reviewer_map = array();
9191
foreach ($this->reviewers as $phid) {
92-
$reviewer_map[$phid] = $this->getHandle($phid)->getFullName();
92+
$reviewer_map[] = $this->getHandle($phid);
9393
}
9494
return id(new AphrontFormTokenizerControl())
9595
->setLabel(pht('Reviewers'))

src/applications/diffusion/controller/DiffusionCommitEditController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function processRequest() {
2727
$commit_phid,
2828
$edge_type);
2929
$handles = $this->loadViewerHandles($current_proj_phids);
30-
$proj_t_values = mpull($handles, 'getFullName', 'getPHID');
30+
$proj_t_values = $handles;
3131

3232
if ($request->isFormPost()) {
3333
$proj_phids = $request->getArr('projects');

src/applications/diffusion/controller/DiffusionLintController.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@ public function processRequest() {
2121
$owners = array();
2222
if (!$drequest) {
2323
if (!$request->getArr('owner')) {
24-
if ($user->isLoggedIn()) {
25-
$owners[$user->getPHID()] = $user->getFullName();
26-
}
24+
$owners = array($user->getPHID());
2725
} else {
28-
$phids = $request->getArr('owner');
29-
$phid = reset($phids);
30-
$handles = $this->loadViewerHandles(array($phid));
31-
$owners[$phid] = $handles[$phid]->getFullName();
26+
$owners = array(head($request->getArr('owner')));
3227
}
28+
$owner_handles = $this->loadViewerHandles($owners);
3329
}
3430

35-
$codes = $this->loadLintCodes(array_keys($owners));
31+
$codes = $this->loadLintCodes($owners);
3632

3733
if ($codes && !$drequest) {
3834
// TODO: Build some real Query classes for this stuff.
@@ -125,7 +121,7 @@ public function processRequest() {
125121
->setLimit(1)
126122
->setName('owner')
127123
->setLabel(pht('Owner'))
128-
->setValue($owners))
124+
->setValue($owner_handles))
129125
->appendChild(
130126
id(new AphrontFormSubmitControl())
131127
->setValue('Filter'));

src/applications/feed/query/PhabricatorFeedSearchEngine.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ public function buildSearchForm(
6666
->setViewer($this->requireViewer())
6767
->withPHIDs($phids)
6868
->execute();
69-
$tokens = mpull($handles, 'getFullName', 'getPHID');
70-
$user_tokens = array_select_keys($tokens, $user_phids);
71-
$proj_tokens = array_select_keys($tokens, $proj_phids);
69+
$user_handles = array_select_keys($handles, $user_phids);
70+
$proj_handles = array_select_keys($handles, $proj_phids);
7271

7372
$viewer_projects = $saved_query->getParameter('viewerProjects');
7473

@@ -78,13 +77,13 @@ public function buildSearchForm(
7877
->setDatasource('/typeahead/common/users/')
7978
->setName('users')
8079
->setLabel(pht('Include Users'))
81-
->setValue($user_tokens))
80+
->setValue($user_handles))
8281
->appendChild(
8382
id(new AphrontFormTokenizerControl())
8483
->setDatasource('/typeahead/common/projects/')
8584
->setName('projectPHIDs')
8685
->setLabel(pht('Include Projects'))
87-
->setValue($proj_tokens))
86+
->setValue($proj_handles))
8887
->appendChild(
8988
id(new AphrontFormCheckboxControl())
9089
->addCheckbox(

src/applications/files/query/PhabricatorFileSearchEngine.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ public function buildSearchForm(
4646
PhabricatorSavedQuery $saved_query) {
4747

4848
$phids = $saved_query->getParameter('authorPHIDs', array());
49-
$handles = id(new PhabricatorHandleQuery())
49+
$author_handles = id(new PhabricatorHandleQuery())
5050
->setViewer($this->requireViewer())
5151
->withPHIDs($phids)
5252
->execute();
53-
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
5453

5554
$explicit = $saved_query->getParameter('explicit');
5655

@@ -60,7 +59,7 @@ public function buildSearchForm(
6059
->setDatasource('/typeahead/common/users/')
6160
->setName('authors')
6261
->setLabel(pht('Authors'))
63-
->setValue($author_tokens))
62+
->setValue($author_handles))
6463
->appendChild(
6564
id(new AphrontFormCheckboxControl())
6665
->addCheckbox(

src/applications/herald/query/HeraldRuleSearchEngine.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ public function buildSearchForm(
5252
PhabricatorSavedQuery $saved_query) {
5353

5454
$phids = $saved_query->getParameter('authorPHIDs', array());
55-
$handles = id(new PhabricatorHandleQuery())
55+
$author_handles = id(new PhabricatorHandleQuery())
5656
->setViewer($this->requireViewer())
5757
->withPHIDs($phids)
5858
->execute();
59-
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
6059

6160
$content_type = $saved_query->getParameter('contentType');
6261
$rule_type = $saved_query->getParameter('ruleType');
@@ -67,7 +66,7 @@ public function buildSearchForm(
6766
->setDatasource('/typeahead/common/users/')
6867
->setName('authors')
6968
->setLabel(pht('Authors'))
70-
->setValue($author_tokens))
69+
->setValue($author_handles))
7170
->appendChild(
7271
id(new AphrontFormSelectControl())
7372
->setName('contentType')

0 commit comments

Comments
 (0)