@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.

Accept `null` via `conduit.edit` to unassign a task

Summary:
See <https://discourse.phabricator-community.org/t/maniphest-edit-to-unassign-owner-documentation-is-wrong/1053>. This unusual field doesn't actually accept `null`, although the documentation says it does and that was the intent.

Accept `null`, and show `phid|null` in the docs.

Test Plan: Viewed docs, saw `phid|null`. Unassigned with `null`.

Reviewers: amckinley

Reviewed By: amckinley

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

+56 -13
+29 -2
src/applications/conduit/parametertype/ConduitPHIDParameterType.php
··· 3 3 final class ConduitPHIDParameterType 4 4 extends ConduitParameterType { 5 5 6 + private $isNullable; 7 + 8 + public function setIsNullable($is_nullable) { 9 + $this->isNullable = $is_nullable; 10 + return $this; 11 + } 12 + 13 + public function getIsNullable() { 14 + return $this->isNullable; 15 + } 16 + 6 17 protected function getParameterValue(array $request, $key, $strict) { 7 18 $value = parent::getParameterValue($request, $key, $strict); 8 19 20 + if ($this->getIsNullable()) { 21 + if ($value === null) { 22 + return $value; 23 + } 24 + } 25 + 9 26 if (!is_string($value)) { 10 27 $this->raiseValidationException( 11 28 $request, ··· 17 34 } 18 35 19 36 protected function getParameterTypeName() { 20 - return 'phid'; 37 + if ($this->getIsNullable()) { 38 + return 'phid|null'; 39 + } else { 40 + return 'phid'; 41 + } 21 42 } 22 43 23 44 protected function getParameterFormatDescriptions() { ··· 27 48 } 28 49 29 50 protected function getParameterExamples() { 30 - return array( 51 + $examples = array( 31 52 '"PHID-WXYZ-1111222233334444"', 32 53 ); 54 + 55 + if ($this->getIsNullable()) { 56 + $examples[] = 'null'; 57 + } 58 + 59 + return $examples; 33 60 } 34 61 35 62 }
+1
src/applications/maniphest/editor/ManiphestEditEngine.php
··· 196 196 pht('New task owner, or `null` to unassign.')) 197 197 ->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE) 198 198 ->setIsCopyable(true) 199 + ->setIsNullable(true) 199 200 ->setSingleValue($object->getOwnerPHID()) 200 201 ->setCommentActionLabel(pht('Assign / Claim')) 201 202 ->setCommentActionValue($owner_value),
+14 -2
src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
··· 5 5 6 6 private $useEdgeTransactions; 7 7 private $isSingleValue; 8 + private $isNullable; 8 9 9 10 public function setUseEdgeTransactions($use_edge_transactions) { 10 11 $this->useEdgeTransactions = $use_edge_transactions; ··· 30 31 return $this->isSingleValue; 31 32 } 32 33 34 + public function setIsNullable($is_nullable) { 35 + $this->isNullable = $is_nullable; 36 + return $this; 37 + } 38 + 39 + public function getIsNullable() { 40 + return $this->isNullable; 41 + } 42 + 33 43 protected function newHTTPParameterType() { 34 44 return new AphrontPHIDListHTTPParameterType(); 35 45 } 36 46 37 47 protected function newConduitParameterType() { 38 48 if ($this->getIsSingleValue()) { 39 - return new ConduitPHIDParameterType(); 49 + return id(new ConduitPHIDParameterType()) 50 + ->setIsNullable($this->getIsNullable()); 40 51 } else { 41 52 return new ConduitPHIDListParameterType(); 42 53 } ··· 99 110 } 100 111 101 112 return id(new PhabricatorDatasourceEditType()) 102 - ->setIsSingleValue($this->getIsSingleValue()); 113 + ->setIsSingleValue($this->getIsSingleValue()) 114 + ->setIsNullable($this->getIsNullable()); 103 115 } 104 116 105 117 protected function newBulkEditTypes() {
+12 -9
src/applications/transactions/edittype/PhabricatorPHIDListEditType.php
··· 6 6 private $datasource; 7 7 private $isSingleValue; 8 8 private $defaultValue; 9 + private $isNullable; 9 10 10 11 public function setDatasource(PhabricatorTypeaheadDatasource $datasource) { 11 12 $this->datasource = $datasource; ··· 30 31 return $this; 31 32 } 32 33 33 - public function getDefaultValue() { 34 - return $this->defaultValue; 34 + public function setIsNullable($is_nullable) { 35 + $this->isNullable = $is_nullable; 36 + return $this; 35 37 } 36 38 37 - public function getValueType() { 38 - if ($this->getIsSingleValue()) { 39 - return 'phid'; 40 - } else { 41 - return 'list<phid>'; 42 - } 39 + public function getIsNullable() { 40 + return $this->isNullable; 41 + } 42 + 43 + public function getDefaultValue() { 44 + return $this->defaultValue; 43 45 } 44 46 45 47 protected function newConduitParameterType() { ··· 49 51 } 50 52 51 53 if ($this->getIsSingleValue()) { 52 - return new ConduitPHIDParameterType(); 54 + return id(new ConduitPHIDParameterType()) 55 + ->setIsNullable($this->getIsNullable()); 53 56 } else { 54 57 return new ConduitPHIDListParameterType(); 55 58 }