mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +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;
|
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() {
|
public function hasComment() {
|
||||||
if (!$this->getComment()) {
|
$comment = $this->getComment();
|
||||||
|
if (!$comment) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = $this->getComment()->getContent();
|
if ($comment->isEmptyComment()) {
|
||||||
|
|
||||||
// If the content is empty or consists of only whitespace, don't count
|
|
||||||
// this as comment.
|
|
||||||
if (!strlen(trim($content))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,18 @@ abstract class PhabricatorApplicationTransactionComment
|
||||||
$this->getTransactionPHID());
|
$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 )----------------------------------------- */
|
/* -( PhabricatorMarkupInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue