mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 21:40:55 +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:
parent
3635a11f84
commit
a529efa5b8
3 changed files with 27 additions and 6 deletions
|
@ -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 )----------------------------------------- */
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue