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

Fix a bug with setting custom PHID list field values via Conduit and prepare for bulk edits

Summary:
Ref T13025. Custom field transactions work somewhat unusually: the values sometimes need to be encoded. We currently do not apply this encoding correctly via Conduit.

For example, setting some custom PHID field to `["PHID-X-Y"]` fails with a bunch of JSON errors.

Add an extra hook callback so that EditTypes can apply processing to transaction values, then apply the correct CustomField processing.

This only affects Conduit. In a future diff, this also allows bulk edit of custom fields to work correctly.

Test Plan: Added a custom field to Maniphest with a list of projects. Used Conduit to bulk edit it (which now works, but did not before). Used the web UI to bulk edit it.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13025

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

+32 -4
+10 -4
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 2169 2169 ->setTransactionType(PhabricatorTransactions::TYPE_CREATE); 2170 2170 } 2171 2171 2172 + $is_strict = $request->getIsStrictlyTyped(); 2173 + 2172 2174 foreach ($xactions as $xaction) { 2173 2175 $type = $types[$xaction['type']]; 2174 2176 ··· 2179 2181 $parameter_type->setViewer($viewer); 2180 2182 2181 2183 try { 2182 - $xaction['value'] = $parameter_type->getValue( 2183 - $xaction, 2184 - 'value', 2185 - $request->getIsStrictlyTyped()); 2184 + $value = $xaction['value']; 2185 + $value = $parameter_type->getValue($xaction, 'value', $is_strict); 2186 + $value = $type->getTransactionValueFromConduit($value); 2187 + $xaction['value'] = $value; 2186 2188 } catch (Exception $ex) { 2187 2189 throw new PhutilProxyException( 2188 2190 pht( ··· 2497 2499 // these are 1:1 and the transaction type just has more internal noise, 2498 2500 // but it's possible that this isn't the case. 2499 2501 $xaction['type'] = $edit_type->getTransactionType(); 2502 + 2503 + $value = $xaction['value']; 2504 + $value = $edit_type->getTransactionValueFromBulkEdit($value); 2505 + $xaction['value'] = $value; 2500 2506 2501 2507 $xaction_objects = $edit_type->generateTransactions( 2502 2508 clone $template,
+12
src/applications/transactions/edittype/PhabricatorEditType.php
··· 91 91 return $this->editField; 92 92 } 93 93 94 + protected function getTransactionValueFromValue($value) { 95 + return $value; 96 + } 97 + 94 98 95 99 /* -( Bulk )--------------------------------------------------------------- */ 96 100 ··· 112 116 113 117 public function getBulkParameterType() { 114 118 return $this->newBulkParameterType(); 119 + } 120 + 121 + public function getTransactionValueFromBulkEdit($value) { 122 + return $this->getTransactionValueFromValue($value); 115 123 } 116 124 117 125 ··· 190 198 } 191 199 192 200 return $this->conduitDocumentation; 201 + } 202 + 203 + public function getTransactionValueFromConduit($value) { 204 + return $this->getTransactionValueFromValue($value); 193 205 } 194 206 195 207 }
+10
src/infrastructure/customfield/editor/PhabricatorCustomFieldEditType.php
··· 40 40 return array($xaction); 41 41 } 42 42 43 + protected function getTransactionValueFromValue($value) { 44 + $field = $this->getCustomField(); 45 + 46 + // Avoid changing the value of the field itself, since later calls would 47 + // incorrectly reflect the new value. 48 + $clone = clone $field; 49 + $clone->setValueFromApplicationTransactions($value); 50 + return $clone->getNewValueForApplicationTransactions(); 51 + } 52 + 43 53 }