@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

Flesh out Conduit parmeter types for maniphest.search

Summary: Ref T9964. I left a couple of these unsupported for now since they're weird in some way.

Test Plan: {F1024031}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9964

Differential Revision: https://secure.phabricator.com/D14767

+69 -3
+2
src/__phutil_library_map__.php
··· 233 233 'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php', 234 234 'ConduitGetCapabilitiesConduitAPIMethod' => 'applications/conduit/method/ConduitGetCapabilitiesConduitAPIMethod.php', 235 235 'ConduitGetCertificateConduitAPIMethod' => 'applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php', 236 + 'ConduitIntListParameterType' => 'applications/conduit/parametertype/ConduitIntListParameterType.php', 236 237 'ConduitIntParameterType' => 'applications/conduit/parametertype/ConduitIntParameterType.php', 237 238 'ConduitListParameterType' => 'applications/conduit/parametertype/ConduitListParameterType.php', 238 239 'ConduitLogGarbageCollector' => 'applications/conduit/garbagecollector/ConduitLogGarbageCollector.php', ··· 4085 4086 'ConduitException' => 'Exception', 4086 4087 'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod', 4087 4088 'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod', 4089 + 'ConduitIntListParameterType' => 'ConduitListParameterType', 4088 4090 'ConduitIntParameterType' => 'ConduitListParameterType', 4089 4091 'ConduitListParameterType' => 'ConduitParameterType', 4090 4092 'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector',
+40
src/applications/conduit/parametertype/ConduitIntListParameterType.php
··· 1 + <?php 2 + 3 + final class ConduitIntListParameterType 4 + extends ConduitListParameterType { 5 + 6 + protected function getParameterValue(array $request, $key) { 7 + $list = parent::getParameterValue($request, $key); 8 + 9 + foreach ($list as $idx => $item) { 10 + if (!is_int($item)) { 11 + $this->raiseValidationException( 12 + $request, 13 + $key, 14 + pht( 15 + 'Expected a list of integers, but item with index "%s" is '. 16 + 'not an integer.', 17 + $idx)); 18 + } 19 + } 20 + 21 + return $this->validateIntList($request, $key, $list); 22 + } 23 + 24 + protected function getParameterTypeName() { 25 + return 'list<int>'; 26 + } 27 + 28 + protected function getParameterFormatDescriptions() { 29 + return array( 30 + pht('List of integers.'), 31 + ); 32 + } 33 + 34 + protected function getParameterExamples() { 35 + return array( 36 + '[123, 0, -456]', 37 + ); 38 + } 39 + 40 + }
+12 -2
src/applications/maniphest/query/ManiphestTaskSearchEngine.php
··· 48 48 id(new PhabricatorOwnersSearchField()) 49 49 ->setLabel(pht('Assigned To')) 50 50 ->setKey('assignedPHIDs') 51 - ->setAliases(array('assigned')), 51 + ->setConduitKey('assigned') 52 + ->setAliases(array('assigned')) 53 + ->setDescription( 54 + pht('Search for tasks owned by a user from a list.')), 52 55 id(new PhabricatorUsersSearchField()) 53 56 ->setLabel(pht('Authors')) 54 57 ->setKey('authorPHIDs') 55 - ->setAliases(array('author', 'authors')), 58 + ->setAliases(array('author', 'authors')) 59 + ->setDescription( 60 + pht('Search for tasks with given authors.')), 56 61 id(new PhabricatorSearchDatasourceField()) 57 62 ->setLabel(pht('Statuses')) 58 63 ->setKey('statuses') 59 64 ->setAliases(array('status')) 65 + ->setDescription( 66 + pht('Search for tasks with given statuses.')) 60 67 ->setDatasource(new ManiphestTaskStatusFunctionDatasource()), 61 68 id(new PhabricatorSearchDatasourceField()) 62 69 ->setLabel(pht('Priorities')) 63 70 ->setKey('priorities') 64 71 ->setAliases(array('priority')) 72 + ->setDescription( 73 + pht('Search for tasks with given priorities.')) 74 + ->setConduitParameterType(new ConduitIntListParameterType()) 65 75 ->setDatasource(new ManiphestTaskPriorityDatasource()), 66 76 id(new PhabricatorSearchTextField()) 67 77 ->setLabel(pht('Contains Words'))
+4
src/applications/owners/searchfield/PhabricatorOwnersSearchField.php
··· 15 15 return new PhabricatorPeopleOwnerDatasource(); 16 16 } 17 17 18 + protected function newConduitParameterType() { 19 + return new ConduitUserListParameterType(); 20 + } 21 + 18 22 }
+11 -1
src/applications/search/field/PhabricatorSearchDatasourceField.php
··· 4 4 extends PhabricatorSearchTokenizerField { 5 5 6 6 private $datasource; 7 + private $conduitParameterType; 7 8 8 9 protected function newDatasource() { 9 10 return id(clone $this->datasource); ··· 11 12 12 13 public function setDatasource(PhabricatorTypeaheadDatasource $datasource) { 13 14 $this->datasource = $datasource; 15 + return $this; 16 + } 17 + 18 + public function setConduitParameterType(ConduitParameterType $type) { 19 + $this->conduitParameterType = $type; 14 20 return $this; 15 21 } 16 22 17 23 protected function newConduitParameterType() { 18 - return new ConduitStringListParameterType(); 24 + if (!$this->conduitParameterType) { 25 + return new ConduitStringListParameterType(); 26 + } 27 + 28 + return $this->conduitParameterType; 19 29 } 20 30 21 31 }