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

Improve behavior of "owner" transaction in "maniphest.edit" endpoint

Summary:
Fixes T10117.

- I accidentally broke setting `null` to unassign tasks at some point when I added richer validation.
- Raise a better error if the user passes junk.

Test Plan:
- Unassigned a task via API and web UI.
- Reassigned a task via API and web UI.
- Tried to do an invalid assign via API, got a sensible error.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10117

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

+85 -1
+2
src/__phutil_library_map__.php
··· 249 249 'ConduitStringParameterType' => 'applications/conduit/parametertype/ConduitStringParameterType.php', 250 250 'ConduitTokenGarbageCollector' => 'applications/conduit/garbagecollector/ConduitTokenGarbageCollector.php', 251 251 'ConduitUserListParameterType' => 'applications/conduit/parametertype/ConduitUserListParameterType.php', 252 + 'ConduitUserParameterType' => 'applications/conduit/parametertype/ConduitUserParameterType.php', 252 253 'ConduitWildParameterType' => 'applications/conduit/parametertype/ConduitWildParameterType.php', 253 254 'ConpherenceColumnViewController' => 'applications/conpherence/controller/ConpherenceColumnViewController.php', 254 255 'ConpherenceConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceConduitAPIMethod.php', ··· 4184 4185 'ConduitStringParameterType' => 'ConduitParameterType', 4185 4186 'ConduitTokenGarbageCollector' => 'PhabricatorGarbageCollector', 4186 4187 'ConduitUserListParameterType' => 'ConduitListParameterType', 4188 + 'ConduitUserParameterType' => 'ConduitParameterType', 4187 4189 'ConduitWildParameterType' => 'ConduitListParameterType', 4188 4190 'ConpherenceColumnViewController' => 'ConpherenceController', 4189 4191 'ConpherenceConduitAPIMethod' => 'ConduitAPIMethod',
+47
src/applications/conduit/parametertype/ConduitUserParameterType.php
··· 1 + <?php 2 + 3 + final class ConduitUserParameterType 4 + extends ConduitParameterType { 5 + 6 + protected function getParameterValue(array $request, $key) { 7 + $value = parent::getParameterValue($request, $key); 8 + 9 + if ($value === null) { 10 + return null; 11 + } 12 + 13 + if (!is_string($value)) { 14 + $this->raiseValidationException( 15 + $request, 16 + $key, 17 + pht('Expected PHID or null, got something else.')); 18 + } 19 + 20 + $user_phids = id(new PhabricatorUserPHIDResolver()) 21 + ->setViewer($this->getViewer()) 22 + ->resolvePHIDs(array($value)); 23 + 24 + return nonempty(head($user_phids), null); 25 + } 26 + 27 + protected function getParameterTypeName() { 28 + return 'phid|string|null'; 29 + } 30 + 31 + protected function getParameterFormatDescriptions() { 32 + return array( 33 + pht('User PHID.'), 34 + pht('Username.'), 35 + pht('Literal null.'), 36 + ); 37 + } 38 + 39 + protected function getParameterExamples() { 40 + return array( 41 + '"PHID-USER-1111"', 42 + '"alincoln"', 43 + 'null', 44 + ); 45 + } 46 + 47 + }
+27
src/applications/maniphest/editor/ManiphestTransactionEditor.php
··· 829 829 last($with_effect)); 830 830 } 831 831 break; 832 + case ManiphestTransaction::TYPE_OWNER: 833 + foreach ($xactions as $xaction) { 834 + $old = $xaction->getOldValue(); 835 + $new = $xaction->getNewValue(); 836 + if (!strlen($new)) { 837 + continue; 838 + } 839 + 840 + if ($new === $old) { 841 + continue; 842 + } 843 + 844 + $assignee_list = id(new PhabricatorPeopleQuery()) 845 + ->setViewer($this->getActor()) 846 + ->withPHIDs(array($new)) 847 + ->execute(); 848 + if (!$assignee_list) { 849 + $errors[] = new PhabricatorApplicationTransactionValidationError( 850 + $type, 851 + pht('Invalid'), 852 + pht( 853 + 'User "%s" is not a valid user.', 854 + $new), 855 + $xaction); 856 + } 857 + } 858 + break; 832 859 } 833 860 834 861 return $errors;
+3
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 1632 1632 array $types, 1633 1633 PhabricatorApplicationTransaction $template) { 1634 1634 1635 + $viewer = $request->getUser(); 1635 1636 $transactions_key = 'transactions'; 1636 1637 1637 1638 $xactions = $request->getValue($transactions_key); ··· 1687 1688 // Let the parameter type interpret the value. This allows you to 1688 1689 // use usernames in list<user> fields, for example. 1689 1690 $parameter_type = $type->getConduitParameterType(); 1691 + 1692 + $parameter_type->setViewer($viewer); 1690 1693 1691 1694 try { 1692 1695 $xaction['value'] = $parameter_type->getValue($xaction, 'value');
+1
src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
··· 100 100 101 101 $type = new PhabricatorDatasourceEditType(); 102 102 $type->setIsSingleValue($this->getIsSingleValue()); 103 + $type->setConduitParameterType($this->newConduitParameterType()); 103 104 return $type; 104 105 } 105 106
+5 -1
src/applications/transactions/editfield/PhabricatorUsersEditField.php
··· 12 12 } 13 13 14 14 protected function newConduitParameterType() { 15 - return new ConduitUserListParameterType(); 15 + if ($this->getIsSingleValue()) { 16 + return new ConduitUserParameterType(); 17 + } else { 18 + return new ConduitUserListParameterType(); 19 + } 16 20 } 17 21 18 22 }