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

Make configured and EditEngine defaults work correctly for custom fields

Summary:
Ref T10004. Fixes T5158. There was a long-standing issue with defaults not working properly, but EditEngine has made it more obvious because it's a lot easier to set defaults now.

The issue is basically that the defaults are getting set as the field's real value early on, so when we go to generate the transaction "old value" later, we build a transaction that uses the //new// value as both the "new value" and "old value". Then the engine says "you didn't change anything, so I'm going to ignore this" and drops it.

To fix this, return `null` as the "old value" by default, and add a call to overwrite that after we load a legitimate old value.

This fix is a touch iffy, but I have some grand plans to clean up the CustomField stuff more broadly later on.

Test Plan:
- Set config defaults on select/typeahead fields, created and edited tasks.
- Set form defaults on select/typehaead fields, created and edited tasks.
- In all cases, transactions and state accurately reflected edits.
- Set defaults on //hidden// fields, verified forms respected them correctly.
- This does generate some fluffy transactions, but I'll deal with those in T7661.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T5158, T10004

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

+23
+7
src/infrastructure/customfield/field/PhabricatorCustomField.php
··· 594 594 throw new PhabricatorCustomFieldImplementationIncompleteException($this); 595 595 } 596 596 597 + public function didSetValueFromStorage() { 598 + if ($this->proxy) { 599 + return $this->proxy->didSetValueFromStorage(); 600 + } 601 + return $this; 602 + } 603 + 597 604 598 605 /* -( ApplicationSearch )-------------------------------------------------- */ 599 606
+2
src/infrastructure/customfield/field/PhabricatorCustomFieldList.php
··· 73 73 $storage = idx($objects, $key); 74 74 if ($storage) { 75 75 $field->setValueFromStorage($storage->getFieldValue()); 76 + $field->didSetValueFromStorage(); 76 77 } else if ($object->getPHID()) { 77 78 // NOTE: We set this only if the object exists. Otherwise, we allow the 78 79 // field to retain any default value it may have. 79 80 $field->setValueFromStorage(null); 81 + $field->didSetValueFromStorage(); 80 82 } 81 83 } 82 84
+14
src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
··· 16 16 private $required; 17 17 private $default; 18 18 private $isCopyable; 19 + private $hasStorageValue; 19 20 20 21 abstract public function getFieldType(); 21 22 ··· 213 214 214 215 public function setValueFromStorage($value) { 215 216 return $this->setFieldValue($value); 217 + } 218 + 219 + public function didSetValueFromStorage() { 220 + $this->hasStorageValue = true; 221 + return $this; 222 + } 223 + 224 + public function getOldValueForApplicationTransactions() { 225 + if ($this->hasStorageValue) { 226 + return $this->getValueForStorage(); 227 + } else { 228 + return null; 229 + } 216 230 } 217 231 218 232 public function shouldAppearInApplicationTransactions() {