1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Fix an issue where inline comments with only edit suggestions are considered empty

Summary:
Ref T13513. An inline is not considered empty if it has a suggestion, but some of the shared transaction code doesn't test for this properly.

Update the shared transaction code to be aware that application comments may have more complex emptiness rules.

Test Plan:
  - Posted an inline with only an edit suggestion, comment went through.
  - Tried to post a normal empty comment, got an appropriate warning.

Maniphest Tasks: T13513

Differential Revision: https://secure.phabricator.com/D21287
This commit is contained in:
epriestley 2020-05-23 08:13:41 -07:00
parent 3635a11f84
commit a529efa5b8
3 changed files with 27 additions and 6 deletions

View file

@ -144,4 +144,16 @@ final class DifferentialTransactionComment
return $this;
}
public function isEmptyComment() {
if (!parent::isEmptyComment()) {
return false;
}
return $this->newInlineCommentObject()
->getContentState()
->isEmptyContentState();
}
}

View file

@ -127,15 +127,12 @@ abstract class PhabricatorApplicationTransaction
}
public function hasComment() {
if (!$this->getComment()) {
$comment = $this->getComment();
if (!$comment) {
return false;
}
$content = $this->getComment()->getContent();
// If the content is empty or consists of only whitespace, don't count
// this as comment.
if (!strlen(trim($content))) {
if ($comment->isEmptyComment()) {
return false;
}

View file

@ -107,6 +107,18 @@ abstract class PhabricatorApplicationTransactionComment
$this->getTransactionPHID());
}
public function isEmptyComment() {
$content = $this->getContent();
// The comment is empty if there's no content, or if the content only has
// whitespace.
if (!strlen(trim($content))) {
return true;
}
return false;
}
/* -( PhabricatorMarkupInterface )----------------------------------------- */