@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Formalize custom Conduit fields on objects

Summary: Ref T9964. This just adds more structure to application fields, to make it harder to make typos and easier to validate them later.

Test Plan: Viewed APIs, called some APIs, saw good documentation and correct results.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9964

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

+141 -90
+2
src/__phutil_library_map__.php
··· 1897 1897 'PhabricatorConduitRequestExceptionHandler' => 'aphront/handler/PhabricatorConduitRequestExceptionHandler.php', 1898 1898 'PhabricatorConduitResultInterface' => 'applications/conduit/interface/PhabricatorConduitResultInterface.php', 1899 1899 'PhabricatorConduitSearchEngine' => 'applications/conduit/query/PhabricatorConduitSearchEngine.php', 1900 + 'PhabricatorConduitSearchFieldSpecification' => 'applications/conduit/interface/PhabricatorConduitSearchFieldSpecification.php', 1900 1901 'PhabricatorConduitTestCase' => '__tests__/PhabricatorConduitTestCase.php', 1901 1902 'PhabricatorConduitToken' => 'applications/conduit/storage/PhabricatorConduitToken.php', 1902 1903 'PhabricatorConduitTokenController' => 'applications/conduit/controller/PhabricatorConduitTokenController.php', ··· 6014 6015 'PhabricatorConduitRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', 6015 6016 'PhabricatorConduitResultInterface' => 'PhabricatorPHIDInterface', 6016 6017 'PhabricatorConduitSearchEngine' => 'PhabricatorApplicationSearchEngine', 6018 + 'PhabricatorConduitSearchFieldSpecification' => 'Phobject', 6017 6019 'PhabricatorConduitTestCase' => 'PhabricatorTestCase', 6018 6020 'PhabricatorConduitToken' => array( 6019 6021 'PhabricatorConduitDAO',
+4 -4
src/applications/conduit/interface/PhabricatorConduitResultInterface.php
··· 16 16 17 17 public function getFieldSpecificationsForConduit() { 18 18 return array( 19 - 'name' => array( 20 - 'type' => 'string', 21 - 'description' => pht('The name of the object.'), 22 - ), 19 + id(new PhabricatorConduitSearchFieldSpecification()) 20 + ->setKey('name') 21 + ->setType('string') 22 + ->setDescription(pht('The name of the object.')), 23 23 ); 24 24 } 25 25
+37
src/applications/conduit/interface/PhabricatorConduitSearchFieldSpecification.php
··· 1 + <?php 2 + 3 + final class PhabricatorConduitSearchFieldSpecification 4 + extends Phobject { 5 + 6 + private $key; 7 + private $type; 8 + private $description; 9 + 10 + public function setKey($key) { 11 + $this->key = $key; 12 + return $this; 13 + } 14 + 15 + public function getKey() { 16 + return $this->key; 17 + } 18 + 19 + public function setType($type) { 20 + $this->type = $type; 21 + return $this; 22 + } 23 + 24 + public function getType() { 25 + return $this->type; 26 + } 27 + 28 + public function setDescription($description) { 29 + $this->description = $description; 30 + return $this; 31 + } 32 + 33 + public function getDescription() { 34 + return $this->description; 35 + } 36 + 37 + }
+24 -24
src/applications/maniphest/storage/ManiphestTask.php
··· 399 399 400 400 public function getFieldSpecificationsForConduit() { 401 401 return array( 402 - 'title' => array( 403 - 'type' => 'string', 404 - 'description' => pht('The name of the object.'), 405 - ), 406 - 'authorPHID' => array( 407 - 'type' => 'phid', 408 - 'description' => pht('Original task author.'), 409 - ), 410 - 'ownerPHID' => array( 411 - 'type' => 'phid?', 412 - 'description' => pht('Current task owner.'), 413 - ), 414 - 'status' => array( 415 - 'type' => 'string', 416 - 'description' => pht('Current task status.'), 417 - ), 418 - 'priority' => array( 419 - 'type' => 'int', 420 - 'description' => pht('Task priority.'), 421 - ), 422 - 'subpriority' => array( 423 - 'type' => 'double', 424 - 'description' => pht('Order within priority level.'), 425 - ), 402 + id(new PhabricatorConduitSearchFieldSpecification()) 403 + ->setKey('title') 404 + ->setType('string') 405 + ->setDescription(pht('The title of the task.')), 406 + id(new PhabricatorConduitSearchFieldSpecification()) 407 + ->setKey('authorPHID') 408 + ->setType('phid') 409 + ->setDescription(pht('Original task author.')), 410 + id(new PhabricatorConduitSearchFieldSpecification()) 411 + ->setKey('ownerPHID') 412 + ->setType('phid?') 413 + ->setDescription(pht('Current task owner, if task is assigned.')), 414 + id(new PhabricatorConduitSearchFieldSpecification()) 415 + ->setKey('status') 416 + ->setType('string') 417 + ->setDescription(pht('Task status.')), 418 + id(new PhabricatorConduitSearchFieldSpecification()) 419 + ->setKey('priority') 420 + ->setType('int') 421 + ->setDescription(pht('Task priority.')), 422 + id(new PhabricatorConduitSearchFieldSpecification()) 423 + ->setKey('subpriority') 424 + ->setType('double') 425 + ->setDescription(pht('Order within priority level.')), 426 426 ); 427 427 } 428 428
+16 -16
src/applications/owners/storage/PhabricatorOwnersPackage.php
··· 391 391 392 392 public function getFieldSpecificationsForConduit() { 393 393 return array( 394 - 'name' => array( 395 - 'type' => 'string', 396 - 'description' => pht('The name of the package.'), 397 - ), 398 - 'description' => array( 399 - 'type' => 'string', 400 - 'description' => pht('The package description.'), 401 - ), 402 - 'status' => array( 403 - 'type' => 'string', 404 - 'description' => pht('Active or archived status of the package.'), 405 - ), 406 - 'owners' => array( 407 - 'type' => 'list<map<string, wild>>', 408 - 'description' => pht('List of package owners.'), 409 - ), 394 + id(new PhabricatorConduitSearchFieldSpecification()) 395 + ->setKey('name') 396 + ->setType('string') 397 + ->setDescription(pht('The name of the package.')), 398 + id(new PhabricatorConduitSearchFieldSpecification()) 399 + ->setKey('description') 400 + ->setType('string') 401 + ->setDescription(pht('The package description.')), 402 + id(new PhabricatorConduitSearchFieldSpecification()) 403 + ->setKey('status') 404 + ->setType('string') 405 + ->setDescription(pht('Active or archived status of the package.')), 406 + id(new PhabricatorConduitSearchFieldSpecification()) 407 + ->setKey('owners') 408 + ->setType('list<map<string, wild>>') 409 + ->setDescription(pht('List of package owners.')), 410 410 ); 411 411 } 412 412
+16 -16
src/applications/paste/storage/PhabricatorPaste.php
··· 257 257 258 258 public function getFieldSpecificationsForConduit() { 259 259 return array( 260 - 'title' => array( 261 - 'type' => 'string', 262 - 'description' => pht('The name of the object.'), 263 - ), 264 - 'authorPHID' => array( 265 - 'type' => 'phid', 266 - 'description' => pht('User PHID of the author.'), 267 - ), 268 - 'language' => array( 269 - 'type' => 'string?', 270 - 'description' => pht('Language to use for syntax highlighting.'), 271 - ), 272 - 'status' => array( 273 - 'type' => 'string', 274 - 'description' => pht('Active or archived status of the paste.'), 275 - ), 260 + id(new PhabricatorConduitSearchFieldSpecification()) 261 + ->setKey('title') 262 + ->setType('string') 263 + ->setDescription(pht('The title of the paste.')), 264 + id(new PhabricatorConduitSearchFieldSpecification()) 265 + ->setKey('authorPHID') 266 + ->setType('phid') 267 + ->setDescription(pht('User PHID of the author.')), 268 + id(new PhabricatorConduitSearchFieldSpecification()) 269 + ->setKey('language') 270 + ->setType('string?') 271 + ->setDescription(pht('Language to use for syntax highlighting.')), 272 + id(new PhabricatorConduitSearchFieldSpecification()) 273 + ->setKey('status') 274 + ->setType('string') 275 + ->setDescription(pht('Active or arhived status of the paste.')), 276 276 ); 277 277 } 278 278
+4 -5
src/applications/policy/engineextension/PhabricatorPolicySearchEngineExtension.php
··· 23 23 24 24 public function getFieldSpecificationsForConduit($object) { 25 25 return array( 26 - 'policy' => array( 27 - 'type' => 'map<string, wild>', 28 - 'description' => pht( 29 - 'Map of capabilities to current policies.'), 30 - ), 26 + id(new PhabricatorConduitSearchFieldSpecification()) 27 + ->setKey('policy') 28 + ->setType('map<string, wild>') 29 + ->setDescription(pht('Map of capabilities to current policies.')), 31 30 ); 32 31 } 33 32
+15 -4
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 1129 1129 $attachments = $this->getConduitSearchAttachments(); 1130 1130 1131 1131 // TODO: Validate this better. 1132 - $attachment_specs = $request->getValue('attachments'); 1132 + $attachment_specs = $request->getValue('attachments', array()); 1133 1133 $attachments = array_select_keys( 1134 1134 $attachments, 1135 1135 array_keys($attachment_specs)); ··· 1203 1203 $extensions = $this->getConduitFieldExtensions(); 1204 1204 $object = $this->newQuery()->newResultObject(); 1205 1205 1206 - $specifications = array(); 1206 + $map = array(); 1207 1207 foreach ($extensions as $extension) { 1208 - $specifications += $extension->getFieldSpecificationsForConduit($object); 1208 + $specifications = $extension->getFieldSpecificationsForConduit($object); 1209 + foreach ($specifications as $specification) { 1210 + $key = $specification->getKey(); 1211 + if (isset($map[$key])) { 1212 + throw new Exception( 1213 + pht( 1214 + 'Two field specifications share the same key ("%s"). Each '. 1215 + 'specification must have a unique key.', 1216 + $key)); 1217 + } 1218 + $map[$key] = $specification; 1219 + } 1209 1220 } 1210 1221 1211 - return $specifications; 1222 + return $map; 1212 1223 } 1213 1224 1214 1225 private function getEngineExtensions() {
+2 -2
src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php
··· 373 373 374 374 $rows = array(); 375 375 foreach ($specs as $key => $spec) { 376 - $type = idx($spec, 'type'); 377 - $description = idx($spec, 'description'); 376 + $type = $spec->getType(); 377 + $description = $spec->getDescription(); 378 378 $rows[] = array( 379 379 $key, 380 380 $type,
+10 -10
src/applications/search/engineextension/PhabricatorLiskSearchEngineExtension.php
··· 31 31 32 32 public function getFieldSpecificationsForConduit($object) { 33 33 return array( 34 - 'dateCreated' => array( 35 - 'type' => 'int', 36 - 'description' => pht( 37 - 'Epoch timestamp when the object was created.'), 38 - ), 39 - 'dateModified' => array( 40 - 'type' => 'int', 41 - 'description' => pht( 42 - 'Epoch timestamp when the object was last updated.'), 43 - ), 34 + id(new PhabricatorConduitSearchFieldSpecification()) 35 + ->setKey('dateCreated') 36 + ->setType('int') 37 + ->setDescription( 38 + pht('Epoch timestamp when the object was created.')), 39 + id(new PhabricatorConduitSearchFieldSpecification()) 40 + ->setKey('dateModified') 41 + ->setType('int') 42 + ->setDescription( 43 + pht('Epoch timestamp when the object was last updated.')), 44 44 ); 45 45 } 46 46
+5 -5
src/applications/spaces/engineextension/PhabricatorSpacesSearchEngineExtension.php
··· 55 55 56 56 public function getFieldSpecificationsForConduit($object) { 57 57 return array( 58 - 'spacePHID' => array( 59 - 'type' => 'phid?', 60 - 'description' => pht( 61 - 'PHID of the policy space this object is part of.'), 62 - ), 58 + id(new PhabricatorConduitSearchFieldSpecification()) 59 + ->setKey('spacePHID') 60 + ->setType('phid?') 61 + ->setDescription( 62 + pht('PHID of the policy space this object is part of.')), 63 63 ); 64 64 } 65 65
+6 -4
src/infrastructure/customfield/engineextension/PhabricatorCustomFieldSearchEngineExtension.php
··· 69 69 $map = array(); 70 70 foreach ($fields->getFields() as $field) { 71 71 $key = $field->getModernFieldKey(); 72 - $map[$key] = array( 73 - 'type' => 'wild', 74 - 'description' => $field->getFieldDescription(), 75 - ); 72 + 73 + // TODO: These should have proper types. 74 + $map[] = id(new PhabricatorConduitSearchFieldSpecification()) 75 + ->setKey($key) 76 + ->setType('wild') 77 + ->setDescription($field->getFieldDescription()); 76 78 } 77 79 78 80 return $map;