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

Implement Differential subscribers as a CustomField

Summary: Ref T3886. Now that a custom field can emit a core transaction, just emit a subscribers transaction.

Test Plan: {F116014}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3886

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

+66 -18
+2
src/__phutil_library_map__.php
··· 464 464 'DifferentialRevisionViewController' => 'applications/differential/controller/DifferentialRevisionViewController.php', 465 465 'DifferentialSearchIndexer' => 'applications/differential/search/DifferentialSearchIndexer.php', 466 466 'DifferentialSubscribeController' => 'applications/differential/controller/DifferentialSubscribeController.php', 467 + 'DifferentialSubscribersField' => 'applications/differential/customfield/DifferentialSubscribersField.php', 467 468 'DifferentialSummaryField' => 'applications/differential/customfield/DifferentialSummaryField.php', 468 469 'DifferentialSummaryFieldSpecification' => 'applications/differential/field/specification/DifferentialSummaryFieldSpecification.php', 469 470 'DifferentialTasksAttacher' => 'applications/differential/DifferentialTasksAttacher.php', ··· 3012 3013 'DifferentialRevisionViewController' => 'DifferentialController', 3013 3014 'DifferentialSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 3014 3015 'DifferentialSubscribeController' => 'DifferentialController', 3016 + 'DifferentialSubscribersField' => 'DifferentialCoreCustomField', 3015 3017 'DifferentialSummaryField' => 'DifferentialCoreCustomField', 3016 3018 'DifferentialSummaryFieldSpecification' => 'DifferentialFreeformFieldSpecification', 3017 3019 'DifferentialTestPlanField' => 'DifferentialCoreCustomField',
+4 -2
src/applications/differential/customfield/DifferentialCoreCustomField.php
··· 14 14 abstract protected function readValueFromRevision( 15 15 DifferentialRevision $revision); 16 16 17 - abstract protected function writeValueToRevision( 17 + protected function writeValueToRevision( 18 18 DifferentialRevision $revision, 19 - $value); 19 + $value) { 20 + throw new PhabricatorCustomFieldImplementationIncompleteException($this); 21 + } 20 22 21 23 protected function isCoreFieldRequired() { 22 24 return false;
-6
src/applications/differential/customfield/DifferentialEditPolicyField.php
··· 20 20 return $revision->getEditPolicy(); 21 21 } 22 22 23 - protected function writeValueToRevision( 24 - DifferentialRevision $revision, 25 - $value) { 26 - $revision->setEditPolicy($value); 27 - } 28 - 29 23 public function readValueFromRequest(AphrontRequest $request) { 30 24 $this->setValue($request->getStr($this->getFieldKey())); 31 25 }
+1 -3
src/applications/differential/customfield/DifferentialRepositoryField.php
··· 29 29 public function readValueFromRequest(AphrontRequest $request) { 30 30 $phids = $request->getArr($this->getFieldKey()); 31 31 $first = head($phids); 32 - $this->setValue(coalesce($first, null)); 32 + $this->setValue(nonempty($first, null)); 33 33 } 34 34 35 35 public function getRequiredHandlePHIDsForEdit() { ··· 41 41 } 42 42 43 43 public function renderEditControl(array $handles) { 44 - 45 44 if ($this->getValue()) { 46 45 $control_value = array_select_keys($handles, array($this->getValue())); 47 46 } else { ··· 97 96 $xaction->renderHandleLink($author_phid), 98 97 $xaction->renderHandleLink($old)); 99 98 } 100 - 101 99 } 102 100 103 101 public function getApplicationTransactionTitleForFeed(
+49
src/applications/differential/customfield/DifferentialSubscribersField.php
··· 1 + <?php 2 + 3 + final class DifferentialSubscribersField 4 + extends DifferentialCoreCustomField { 5 + 6 + public function getFieldKey() { 7 + return 'differential:subscribers'; 8 + } 9 + 10 + public function getFieldName() { 11 + return pht('Subscribers'); 12 + } 13 + 14 + public function getFieldDescription() { 15 + return pht('Manage subscribers.'); 16 + } 17 + 18 + protected function readValueFromRevision( 19 + DifferentialRevision $revision) { 20 + return PhabricatorSubscribersQuery::loadSubscribersForPHID( 21 + $revision->getPHID()); 22 + } 23 + 24 + public function getNewValueForApplicationTransactions() { 25 + return array('=' => $this->getValue()); 26 + } 27 + 28 + public function readValueFromRequest(AphrontRequest $request) { 29 + $this->setValue($request->getArr($this->getFieldKey())); 30 + } 31 + 32 + public function getRequiredHandlePHIDsForEdit() { 33 + return $this->getValue(); 34 + } 35 + 36 + public function renderEditControl(array $handles) { 37 + return id(new AphrontFormTokenizerControl()) 38 + ->setName($this->getFieldKey()) 39 + ->setDatasource('/typeahead/common/mailable/') 40 + ->setValue($handles) 41 + ->setError($this->getFieldError()) 42 + ->setLabel($this->getFieldName()); 43 + } 44 + 45 + public function getApplicationTransactionType() { 46 + return PhabricatorTransactions::TYPE_SUBSCRIBERS; 47 + } 48 + 49 + }
-6
src/applications/differential/customfield/DifferentialViewPolicyField.php
··· 20 20 return $revision->getViewPolicy(); 21 21 } 22 22 23 - protected function writeValueToRevision( 24 - DifferentialRevision $revision, 25 - $value) { 26 - $revision->setViewPolicy($value); 27 - } 28 - 29 23 public function readValueFromRequest(AphrontRequest $request) { 30 24 $this->setValue($request->getStr($this->getFieldKey())); 31 25 }
+4
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 58 58 case PhabricatorTransactions::TYPE_EDIT_POLICY: 59 59 $object->setEditPolicy($xaction->getNewValue()); 60 60 return; 61 + case PhabricatorTransactions::TYPE_SUBSCRIBERS: 62 + return; 61 63 } 62 64 63 65 return parent::applyCustomInternalTransaction($object, $xaction); ··· 70 72 switch ($xaction->getTransactionType()) { 71 73 case PhabricatorTransactions::TYPE_VIEW_POLICY: 72 74 case PhabricatorTransactions::TYPE_EDIT_POLICY: 75 + return; 76 + case PhabricatorTransactions::TYPE_SUBSCRIBERS: 73 77 return; 74 78 } 75 79
+1
src/applications/differential/storage/DifferentialRevision.php
··· 469 469 new DifferentialTitleField(), 470 470 new DifferentialSummaryField(), 471 471 new DifferentialTestPlanField(), 472 + new DifferentialSubscribersField(), 472 473 new DifferentialRepositoryField(), 473 474 new DifferentialViewPolicyField(), 474 475 new DifferentialEditPolicyField(),
+5 -1
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 186 186 public function getHandle($phid) { 187 187 if (empty($this->handles[$phid])) { 188 188 throw new Exception( 189 - "Transaction requires a handle ('{$phid}') it did not load."); 189 + pht( 190 + 'Transaction ("%s") requires a handle ("%s") that it did not '. 191 + 'load.', 192 + $this->getPHID(), 193 + $phid)); 190 194 } 191 195 return $this->handles[$phid]; 192 196 }