@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 two issues with embedding other fields inside "Summary" or "Test Plan" in Differential with the web UI

Summary:
Ref T11114. Converting to EditEngine caused us to stop running this validation, since these fields no longer subclass this parent. Restore the validation.

Also, make sure we check the //first// line of the value, too. After the change to make "Tests: xyz" a valid title, you could write silly summaries / test plans and escape the check if the first line was bogus.

Test Plan: {F2493228}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11114

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

+71 -42
-41
src/applications/differential/customfield/DifferentialCoreCustomField.php
··· 64 64 continue; 65 65 } 66 66 } 67 - 68 - if (is_string($value)) { 69 - $parser = $this->getFieldParser(); 70 - $result = $parser->parseCorpus($value); 71 - 72 - unset($result['__title__']); 73 - unset($result['__summary__']); 74 - 75 - if ($result) { 76 - $error = new PhabricatorApplicationTransactionValidationError( 77 - $type, 78 - pht('Invalid'), 79 - pht( 80 - 'The value you have entered in "%s" can not be parsed '. 81 - 'unambiguously when rendered in a commit message. Edit the '. 82 - 'message so that keywords like "Summary:" and "Test Plan:" do '. 83 - 'not appear at the beginning of lines. Parsed keys: %s.', 84 - $this->getFieldName(), 85 - implode(', ', array_keys($result))), 86 - $xaction); 87 - $errors[] = $error; 88 - $this->setFieldError(pht('Invalid')); 89 - continue; 90 - } 91 - } 92 67 } 93 68 94 69 return $errors; 95 - } 96 - 97 - private function getFieldParser() { 98 - if (!$this->fieldParser) { 99 - $viewer = $this->getViewer(); 100 - $parser = DifferentialCommitMessageParser::newStandardParser($viewer); 101 - 102 - // Set custom title and summary keys so we can detect the presence of 103 - // "Summary:" in, e.g., a test plan. 104 - $parser->setTitleKey('__title__'); 105 - $parser->setSummaryKey('__summary__'); 106 - 107 - $this->fieldParser = $parser; 108 - } 109 - 110 - return $this->fieldParser; 111 70 } 112 71 113 72 public function canDisableField() {
+7
src/applications/differential/field/DifferentialTestPlanCommitMessageField.php
··· 50 50 ); 51 51 } 52 52 53 + public function validateTransactions($object, array $xactions) { 54 + return $this->validateCommitMessageCorpusTransactions( 55 + $object, 56 + $xactions, 57 + pht('Test Plan')); 58 + } 59 + 53 60 }
+7
src/applications/differential/xaction/DifferentialRevisionSummaryTransaction.php
··· 54 54 return $changes; 55 55 } 56 56 57 + public function validateTransactions($object, array $xactions) { 58 + return $this->validateCommitMessageCorpusTransactions( 59 + $object, 60 + $xactions, 61 + pht('Summary')); 62 + } 63 + 57 64 }
+57 -1
src/applications/differential/xaction/DifferentialRevisionTransactionType.php
··· 1 1 <?php 2 2 3 3 abstract class DifferentialRevisionTransactionType 4 - extends PhabricatorModularTransactionType {} 4 + extends PhabricatorModularTransactionType { 5 + 6 + protected function validateCommitMessageCorpusTransactions( 7 + $object, 8 + array $xactions, 9 + $field_name) { 10 + 11 + $errors = array(); 12 + foreach ($xactions as $xaction) { 13 + $error = $this->validateMessageCorpus($xaction, $field_name); 14 + if ($error) { 15 + $errors[] = $error; 16 + } 17 + } 18 + 19 + return $errors; 20 + } 21 + 22 + private function validateMessageCorpus($xaction, $field_name) { 23 + $value = $xaction->getNewValue(); 24 + if (!strlen($value)) { 25 + return null; 26 + } 27 + 28 + // Put a placeholder title on the message, because the first line of a 29 + // message is now always parsed as a title. 30 + $value = "<placeholder>\n".$value; 31 + 32 + $viewer = $this->getActor(); 33 + $parser = DifferentialCommitMessageParser::newStandardParser($viewer); 34 + 35 + // Set custom title and summary keys so we can detect the presence of 36 + // "Summary:" in, e.g., a test plan. 37 + $parser->setTitleKey('__title__'); 38 + $parser->setSummaryKey('__summary__'); 39 + 40 + $result = $parser->parseCorpus($value); 41 + 42 + unset($result['__title__']); 43 + unset($result['__summary__']); 44 + 45 + if (!$result) { 46 + return null; 47 + } 48 + 49 + return $this->newInvalidError( 50 + pht( 51 + 'The value you have entered in "%s" can not be parsed '. 52 + 'unambiguously when rendered in a commit message. Edit the '. 53 + 'message so that keywords like "Summary:" and "Test Plan:" do '. 54 + 'not appear at the beginning of lines. Parsed keys: %s.', 55 + $field_name, 56 + implode(', ', array_keys($result))), 57 + $xaction); 58 + } 59 + 60 + }