Page MenuHomePhabricator

D18976.diff
No OneTemporary

D18976.diff

diff --git a/src/applications/conduit/parametertype/ConduitPHIDParameterType.php b/src/applications/conduit/parametertype/ConduitPHIDParameterType.php
--- a/src/applications/conduit/parametertype/ConduitPHIDParameterType.php
+++ b/src/applications/conduit/parametertype/ConduitPHIDParameterType.php
@@ -3,9 +3,26 @@
final class ConduitPHIDParameterType
extends ConduitParameterType {
+ private $isNullable;
+
+ public function setIsNullable($is_nullable) {
+ $this->isNullable = $is_nullable;
+ return $this;
+ }
+
+ public function getIsNullable() {
+ return $this->isNullable;
+ }
+
protected function getParameterValue(array $request, $key, $strict) {
$value = parent::getParameterValue($request, $key, $strict);
+ if ($this->getIsNullable()) {
+ if ($value === null) {
+ return $value;
+ }
+ }
+
if (!is_string($value)) {
$this->raiseValidationException(
$request,
@@ -17,7 +34,11 @@
}
protected function getParameterTypeName() {
- return 'phid';
+ if ($this->getIsNullable()) {
+ return 'phid|null';
+ } else {
+ return 'phid';
+ }
}
protected function getParameterFormatDescriptions() {
@@ -27,9 +48,15 @@
}
protected function getParameterExamples() {
- return array(
+ $examples = array(
'"PHID-WXYZ-1111222233334444"',
);
+
+ if ($this->getIsNullable()) {
+ $examples[] = 'null';
+ }
+
+ return $examples;
}
}
diff --git a/src/applications/maniphest/editor/ManiphestEditEngine.php b/src/applications/maniphest/editor/ManiphestEditEngine.php
--- a/src/applications/maniphest/editor/ManiphestEditEngine.php
+++ b/src/applications/maniphest/editor/ManiphestEditEngine.php
@@ -196,6 +196,7 @@
pht('New task owner, or `null` to unassign.'))
->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE)
->setIsCopyable(true)
+ ->setIsNullable(true)
->setSingleValue($object->getOwnerPHID())
->setCommentActionLabel(pht('Assign / Claim'))
->setCommentActionValue($owner_value),
diff --git a/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php b/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
--- a/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
+++ b/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
@@ -5,6 +5,7 @@
private $useEdgeTransactions;
private $isSingleValue;
+ private $isNullable;
public function setUseEdgeTransactions($use_edge_transactions) {
$this->useEdgeTransactions = $use_edge_transactions;
@@ -30,13 +31,23 @@
return $this->isSingleValue;
}
+ public function setIsNullable($is_nullable) {
+ $this->isNullable = $is_nullable;
+ return $this;
+ }
+
+ public function getIsNullable() {
+ return $this->isNullable;
+ }
+
protected function newHTTPParameterType() {
return new AphrontPHIDListHTTPParameterType();
}
protected function newConduitParameterType() {
if ($this->getIsSingleValue()) {
- return new ConduitPHIDParameterType();
+ return id(new ConduitPHIDParameterType())
+ ->setIsNullable($this->getIsNullable());
} else {
return new ConduitPHIDListParameterType();
}
@@ -99,7 +110,8 @@
}
return id(new PhabricatorDatasourceEditType())
- ->setIsSingleValue($this->getIsSingleValue());
+ ->setIsSingleValue($this->getIsSingleValue())
+ ->setIsNullable($this->getIsNullable());
}
protected function newBulkEditTypes() {
diff --git a/src/applications/transactions/edittype/PhabricatorPHIDListEditType.php b/src/applications/transactions/edittype/PhabricatorPHIDListEditType.php
--- a/src/applications/transactions/edittype/PhabricatorPHIDListEditType.php
+++ b/src/applications/transactions/edittype/PhabricatorPHIDListEditType.php
@@ -6,6 +6,7 @@
private $datasource;
private $isSingleValue;
private $defaultValue;
+ private $isNullable;
public function setDatasource(PhabricatorTypeaheadDatasource $datasource) {
$this->datasource = $datasource;
@@ -30,16 +31,17 @@
return $this;
}
- public function getDefaultValue() {
- return $this->defaultValue;
+ public function setIsNullable($is_nullable) {
+ $this->isNullable = $is_nullable;
+ return $this;
}
- public function getValueType() {
- if ($this->getIsSingleValue()) {
- return 'phid';
- } else {
- return 'list<phid>';
- }
+ public function getIsNullable() {
+ return $this->isNullable;
+ }
+
+ public function getDefaultValue() {
+ return $this->defaultValue;
}
protected function newConduitParameterType() {
@@ -49,7 +51,8 @@
}
if ($this->getIsSingleValue()) {
- return new ConduitPHIDParameterType();
+ return id(new ConduitPHIDParameterType())
+ ->setIsNullable($this->getIsNullable());
} else {
return new ConduitPHIDListParameterType();
}

File Metadata

Mime Type
text/plain
Expires
Sat, Sep 21, 12:55 AM (17 h, 54 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6624546
Default Alt Text
D18976.diff (4 KB)

Event Timeline