Commit 38991188 authored by epriestley's avatar epriestley
Browse files

(stable) 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
parent 4042ea64
......@@ -144,4 +144,16 @@ final class DifferentialTransactionComment
return $this;
}
public function isEmptyComment() {
if (!parent::isEmptyComment()) {
return false;
}
return $this->newInlineCommentObject()
->getContentState()
->isEmptyContentState();
}
}
......@@ -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;
}
......
......@@ -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 )----------------------------------------- */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment