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

Remove Differential "Title" custom field

Summary: Ref T11114. Obsoleted by Modular Transactions + EditEngine + CommitMessageField + we just "hard code" the title of revisions into the page because we're craaazy.

Test Plan:
- Made an edit on `stable`.
- Viewed the edit on this change, it still had the proper UI strings.
- Edited/created/updated revisions.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11114

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

+22 -129
-2
src/__phutil_library_map__.php
··· 572 572 'DifferentialTestPlanCommitMessageField' => 'applications/differential/field/DifferentialTestPlanCommitMessageField.php', 573 573 'DifferentialTestPlanField' => 'applications/differential/customfield/DifferentialTestPlanField.php', 574 574 'DifferentialTitleCommitMessageField' => 'applications/differential/field/DifferentialTitleCommitMessageField.php', 575 - 'DifferentialTitleField' => 'applications/differential/customfield/DifferentialTitleField.php', 576 575 'DifferentialTransaction' => 'applications/differential/storage/DifferentialTransaction.php', 577 576 'DifferentialTransactionComment' => 'applications/differential/storage/DifferentialTransactionComment.php', 578 577 'DifferentialTransactionEditor' => 'applications/differential/editor/DifferentialTransactionEditor.php', ··· 5236 5235 'DifferentialTestPlanCommitMessageField' => 'DifferentialCommitMessageField', 5237 5236 'DifferentialTestPlanField' => 'DifferentialCoreCustomField', 5238 5237 'DifferentialTitleCommitMessageField' => 'DifferentialCommitMessageField', 5239 - 'DifferentialTitleField' => 'DifferentialCoreCustomField', 5240 5238 'DifferentialTransaction' => 'PhabricatorModularTransaction', 5241 5239 'DifferentialTransactionComment' => 'PhabricatorApplicationTransactionComment', 5242 5240 'DifferentialTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
-1
src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
··· 25 25 $custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType'; 26 26 27 27 $fields = array( 28 - new DifferentialTitleField(), 29 28 new DifferentialSummaryField(), 30 29 new DifferentialTestPlanField(), 31 30 new DifferentialReviewersField(),
-125
src/applications/differential/customfield/DifferentialTitleField.php
··· 1 - <?php 2 - 3 - final class DifferentialTitleField 4 - extends DifferentialCoreCustomField { 5 - 6 - public function getFieldKey() { 7 - return 'differential:title'; 8 - } 9 - 10 - public function getFieldKeyForConduit() { 11 - return 'title'; 12 - } 13 - 14 - public function getFieldName() { 15 - return pht('Title'); 16 - } 17 - 18 - public function getFieldDescription() { 19 - return pht('Stores the revision title.'); 20 - } 21 - 22 - public static function getDefaultTitle() { 23 - return pht('<<Replace this line with your Revision Title>>'); 24 - } 25 - 26 - protected function readValueFromRevision( 27 - DifferentialRevision $revision) { 28 - return $revision->getTitle(); 29 - } 30 - 31 - protected function writeValueToRevision( 32 - DifferentialRevision $revision, 33 - $value) { 34 - $revision->setTitle($value); 35 - } 36 - 37 - protected function getCoreFieldRequiredErrorString() { 38 - return pht('You must choose a title for this revision.'); 39 - } 40 - 41 - public function readValueFromRequest(AphrontRequest $request) { 42 - $this->setValue($request->getStr($this->getFieldKey())); 43 - } 44 - 45 - protected function isCoreFieldRequired() { 46 - return true; 47 - } 48 - 49 - public function renderEditControl(array $handles) { 50 - return id(new AphrontFormTextAreaControl()) 51 - ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT) 52 - ->setName($this->getFieldKey()) 53 - ->setValue($this->getValue()) 54 - ->setError($this->getFieldError()) 55 - ->setLabel($this->getFieldName()); 56 - } 57 - 58 - public function getApplicationTransactionTitle( 59 - PhabricatorApplicationTransaction $xaction) { 60 - $author_phid = $xaction->getAuthorPHID(); 61 - $old = $xaction->getOldValue(); 62 - $new = $xaction->getNewValue(); 63 - 64 - if (strlen($old)) { 65 - return pht( 66 - '%s retitled this revision from "%s" to "%s".', 67 - $xaction->renderHandleLink($author_phid), 68 - $old, 69 - $new); 70 - } else { 71 - return pht( 72 - '%s created this revision.', 73 - $xaction->renderHandleLink($author_phid)); 74 - } 75 - } 76 - 77 - public function getApplicationTransactionTitleForFeed( 78 - PhabricatorApplicationTransaction $xaction) { 79 - 80 - $object_phid = $xaction->getObjectPHID(); 81 - $author_phid = $xaction->getAuthorPHID(); 82 - $old = $xaction->getOldValue(); 83 - $new = $xaction->getNewValue(); 84 - 85 - if (strlen($old)) { 86 - return pht( 87 - '%s retitled %s, from "%s" to "%s".', 88 - $xaction->renderHandleLink($author_phid), 89 - $xaction->renderHandleLink($object_phid), 90 - $old, 91 - $new); 92 - } else { 93 - return pht( 94 - '%s created %s.', 95 - $xaction->renderHandleLink($author_phid), 96 - $xaction->renderHandleLink($object_phid)); 97 - } 98 - } 99 - 100 - public function shouldAppearInCommitMessage() { 101 - return true; 102 - } 103 - 104 - public function shouldOverwriteWhenCommitMessageIsEdited() { 105 - return true; 106 - } 107 - 108 - public function validateCommitMessageValue($value) { 109 - if (!strlen($value)) { 110 - throw new DifferentialFieldValidationException( 111 - pht( 112 - 'You must provide a revision title in the first line '. 113 - 'of your commit message.')); 114 - } 115 - 116 - if (preg_match('/^<<.*>>$/', $value)) { 117 - throw new DifferentialFieldValidationException( 118 - pht( 119 - 'Replace the line "%s" with a human-readable revision title which '. 120 - 'describes the changes you are making.', 121 - self::getDefaultTitle())); 122 - } 123 - } 124 - 125 - }
+17
src/applications/differential/storage/DifferentialTransaction.php
··· 22 22 return 'DifferentialRevisionTransactionType'; 23 23 } 24 24 25 + protected function newFallbackModularTransactionType() { 26 + // TODO: This allows us to render modern strings for older transactions 27 + // without doing a migration. At some point, we should do a migration and 28 + // throw this away. 29 + 30 + $xaction_type = $this->getTransactionType(); 31 + if ($xaction_type == PhabricatorTransactions::TYPE_CUSTOMFIELD) { 32 + switch ($this->getMetadataValue('customfield:key')) { 33 + case 'differential:title': 34 + return new DifferentialRevisionTitleTransaction(); 35 + } 36 + } 37 + 38 + return parent::newFallbackModularTransactionType(); 39 + } 40 + 41 + 25 42 public function setIsCommandeerSideEffect($is_side_effect) { 26 43 $this->isCommandeerSideEffect = $is_side_effect; 27 44 return $this;
+5 -1
src/applications/transactions/storage/PhabricatorModularTransaction.php
··· 46 46 $key = $this->getTransactionType(); 47 47 48 48 if (empty($types[$key])) { 49 - $type = new PhabricatorCoreVoidTransaction(); 49 + $type = $this->newFallbackModularTransactionType(); 50 50 } else { 51 51 $type = clone $types[$key]; 52 52 } ··· 54 54 $type->setStorage($this); 55 55 56 56 return $type; 57 + } 58 + 59 + protected function newFallbackModularTransactionType() { 60 + return new PhabricatorCoreVoidTransaction(); 57 61 } 58 62 59 63 final public function generateOldValue($object) {