Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15367459
D12027.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D12027.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -339,6 +339,7 @@
'DifferentialDiff' => 'applications/differential/storage/DifferentialDiff.php',
'DifferentialDiffCreateController' => 'applications/differential/controller/DifferentialDiffCreateController.php',
'DifferentialDiffEditor' => 'applications/differential/editor/DifferentialDiffEditor.php',
+ 'DifferentialDiffInlineCommentQuery' => 'applications/differential/query/DifferentialDiffInlineCommentQuery.php',
'DifferentialDiffPHIDType' => 'applications/differential/phid/DifferentialDiffPHIDType.php',
'DifferentialDiffProperty' => 'applications/differential/storage/DifferentialDiffProperty.php',
'DifferentialDiffQuery' => 'applications/differential/query/DifferentialDiffQuery.php',
@@ -1692,6 +1693,7 @@
'PhabricatorDestructionEngine' => 'applications/system/engine/PhabricatorDestructionEngine.php',
'PhabricatorDeveloperConfigOptions' => 'applications/config/option/PhabricatorDeveloperConfigOptions.php',
'PhabricatorDeveloperPreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorDeveloperPreferencesSettingsPanel.php',
+ 'PhabricatorDiffInlineCommentQuery' => 'infrastructure/diff/query/PhabricatorDiffInlineCommentQuery.php',
'PhabricatorDiffPreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorDiffPreferencesSettingsPanel.php',
'PhabricatorDifferenceEngine' => 'infrastructure/diff/PhabricatorDifferenceEngine.php',
'PhabricatorDifferentialApplication' => 'applications/differential/application/PhabricatorDifferentialApplication.php',
@@ -3487,6 +3489,7 @@
),
'DifferentialDiffCreateController' => 'DifferentialController',
'DifferentialDiffEditor' => 'PhabricatorApplicationTransactionEditor',
+ 'DifferentialDiffInlineCommentQuery' => 'PhabricatorDiffInlineCommentQuery',
'DifferentialDiffPHIDType' => 'PhabricatorPHIDType',
'DifferentialDiffProperty' => 'DifferentialDAO',
'DifferentialDiffQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
@@ -4974,6 +4977,7 @@
'PhabricatorDestructionEngine' => 'Phobject',
'PhabricatorDeveloperConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorDeveloperPreferencesSettingsPanel' => 'PhabricatorSettingsPanel',
+ 'PhabricatorDiffInlineCommentQuery' => 'PhabricatorApplicationTransactionCommentQuery',
'PhabricatorDiffPreferencesSettingsPanel' => 'PhabricatorSettingsPanel',
'PhabricatorDifferentialApplication' => 'PhabricatorApplication',
'PhabricatorDifferentialConfigOptions' => 'PhabricatorApplicationConfigOptions',
diff --git a/src/applications/differential/query/DifferentialDiffInlineCommentQuery.php b/src/applications/differential/query/DifferentialDiffInlineCommentQuery.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/query/DifferentialDiffInlineCommentQuery.php
@@ -0,0 +1,31 @@
+<?php
+
+final class DifferentialDiffInlineCommentQuery
+ extends PhabricatorDiffInlineCommentQuery {
+
+ private $revisionPHIDs;
+
+ public function withRevisionPHIDs(array $phids) {
+ $this->revisionPHIDs = $phids;
+ return $this;
+ }
+
+ protected function getTemplate() {
+ return new DifferentialTransactionComment();
+ }
+
+ protected function buildWhereClauseComponents(
+ AphrontDatabaseConnection $conn_r) {
+ $where = parent::buildWhereClauseComponents($conn_r);
+
+ if ($this->revisionPHIDs !== null) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'revisionPHID IN (%Ls)',
+ $this->revisionPHIDs);
+ }
+
+ return $where;
+ }
+
+}
diff --git a/src/applications/differential/query/DifferentialTransactionQuery.php b/src/applications/differential/query/DifferentialTransactionQuery.php
--- a/src/applications/differential/query/DifferentialTransactionQuery.php
+++ b/src/applications/differential/query/DifferentialTransactionQuery.php
@@ -11,38 +11,14 @@
PhabricatorUser $viewer,
DifferentialRevision $revision) {
- // TODO: Subclass ApplicationTransactionCommentQuery to do this for real.
-
- $table = new DifferentialTransactionComment();
- $conn_r = $table->establishConnection('r');
-
- $phids = queryfx_all(
- $conn_r,
- 'SELECT phid FROM %T
- WHERE revisionPHID = %s
- AND authorPHID = %s
- AND transactionPHID IS NULL
- AND isDeleted = 0',
- $table->getTableName(),
- $revision->getPHID(),
- $viewer->getPHID());
-
- $phids = ipull($phids, 'phid');
- if (!$phids) {
- return array();
- }
-
- $comments = id(new PhabricatorApplicationTransactionTemplatedCommentQuery())
- ->setTemplate(new DifferentialTransactionComment())
+ return id(new DifferentialDiffInlineCommentQuery())
->setViewer($viewer)
- ->withPHIDs($phids)
+ ->withRevisionPHIDs(array($revision->getPHID()))
+ ->withAuthorPHIDs(array($viewer->getPHID()))
+ ->withHasTransaction(false)
+ ->withIsDeleted(false)
+ ->needReplyToComments(true)
->execute();
-
- $comments = PhabricatorInlineCommentController::loadAndAttachReplies(
- $viewer,
- $comments);
-
- return $comments;
}
}
diff --git a/src/applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php b/src/applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php
--- a/src/applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php
+++ b/src/applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php
@@ -8,6 +8,7 @@
private $phids;
private $transactionPHIDs;
private $isDeleted;
+ private $hasTransaction;
abstract protected function getTemplate();
@@ -31,11 +32,16 @@
return $this;
}
- public function withDeleted($deleted) {
+ public function withIsDeleted($deleted) {
$this->isDeleted = $deleted;
return $this;
}
+ public function withHasTransaction($has_transaction) {
+ $this->hasTransaction = $has_transaction;
+ return $this;
+ }
+
protected function loadPage() {
$table = $this->getTemplate();
$conn_r = $table->establishConnection('r');
@@ -51,7 +57,13 @@
return $table->loadAllFromArray($data);
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
+ private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
+ return $this->formatWhereClause($this->buildWhereClauseComponents($conn_r));
+ }
+
+ protected function buildWhereClauseComponents(
+ AphrontDatabaseConnection $conn_r) {
+
$where = array();
if ($this->ids !== null) {
@@ -89,7 +101,19 @@
(int)$this->isDeleted);
}
- return $this->formatWhereClause($where);
+ if ($this->hasTransaction !== null) {
+ if ($this->hasTransaction) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'xcomment.transactionPHID IS NOT NULL');
+ } else {
+ $where[] = qsprintf(
+ $conn_r,
+ 'xcomment.transactionPHID IS NULL');
+ }
+ }
+
+ return $where;
}
public function getQueryApplicationClass() {
diff --git a/src/infrastructure/diff/query/PhabricatorDiffInlineCommentQuery.php b/src/infrastructure/diff/query/PhabricatorDiffInlineCommentQuery.php
new file mode 100644
--- /dev/null
+++ b/src/infrastructure/diff/query/PhabricatorDiffInlineCommentQuery.php
@@ -0,0 +1,53 @@
+<?php
+
+abstract class PhabricatorDiffInlineCommentQuery
+ extends PhabricatorApplicationTransactionCommentQuery {
+
+ private $needReplyToComments;
+
+ public function needReplyToComments($need_reply_to) {
+ $this->needReplyToComments = $need_reply_to;
+ return $this;
+ }
+
+ protected function willFilterPage(array $comments) {
+ if ($this->needReplyToComments) {
+ $reply_phids = array();
+ foreach ($comments as $comment) {
+ $reply_phid = $comment->getReplyToCommentPHID();
+ if ($reply_phid) {
+ $reply_phids[] = $reply_phid;
+ }
+ }
+
+ if ($reply_phids) {
+ $reply_comments = newv(get_class($this), array())
+ ->setViewer($this->getViewer())
+ ->setParentQuery($this)
+ ->withPHIDs($reply_phids)
+ ->execute();
+ $reply_comments = mpull($reply_comments, null, 'getPHID');
+ } else {
+ $reply_comments = array();
+ }
+
+ foreach ($comments as $key => $comment) {
+ $reply_phid = $comment->getReplyToCommentPHID();
+ if (!$reply_phid) {
+ $comment->attachReplyToComment(null);
+ continue;
+ }
+ $reply = idx($reply_comments, $reply_phid);
+ if (!$reply) {
+ $this->didRejectResult($comment);
+ unset($comments[$key]);
+ continue;
+ }
+ $comment->attachReplyToComment($reply);
+ }
+ }
+
+ return $comments;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 12, 6:51 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7592170
Default Alt Text
D12027.diff (8 KB)
Attached To
Mode
D12027: Extend TransactionCommentQuery for Differential
Attached
Detach File
Event Timeline
Log In to Comment