Page MenuHomePhabricator

D21486.diff
No OneTemporary

D21486.diff

diff --git a/src/applications/metamta/query/PhabricatorMetaMTAMailQuery.php b/src/applications/metamta/query/PhabricatorMetaMTAMailQuery.php
--- a/src/applications/metamta/query/PhabricatorMetaMTAMailQuery.php
+++ b/src/applications/metamta/query/PhabricatorMetaMTAMailQuery.php
@@ -64,24 +64,6 @@
$this->actorPHIDs);
}
- if ($this->recipientPHIDs !== null) {
- $where[] = qsprintf(
- $conn,
- 'recipient.dst IN (%Ls)',
- $this->recipientPHIDs);
- }
-
- if ($this->actorPHIDs === null && $this->recipientPHIDs === null) {
- $viewer = $this->getViewer();
- if (!$viewer->isOmnipotent()) {
- $where[] = qsprintf(
- $conn,
- 'edge.dst = %s OR actorPHID = %s',
- $viewer->getPHID(),
- $viewer->getPHID());
- }
- }
-
if ($this->createdMin !== null) {
$where[] = qsprintf(
$conn,
@@ -102,24 +84,27 @@
protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {
$joins = parent::buildJoinClauseParts($conn);
- if ($this->actorPHIDs === null && $this->recipientPHIDs === null) {
+ if ($this->shouldJoinRecipients()) {
$joins[] = qsprintf(
$conn,
- 'LEFT JOIN %T edge ON mail.phid = edge.src AND edge.type = %d',
+ 'JOIN %T recipient
+ ON mail.phid = recipient.src
+ AND recipient.type = %d
+ AND recipient.dst IN (%Ls)',
PhabricatorEdgeConfig::TABLE_NAME_EDGE,
- PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST);
+ PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST,
+ $this->recipientPHIDs);
}
- if ($this->recipientPHIDs !== null) {
- $joins[] = qsprintf(
- $conn,
- 'LEFT JOIN %T recipient '.
- 'ON mail.phid = recipient.src AND recipient.type = %d',
- PhabricatorEdgeConfig::TABLE_NAME_EDGE,
- PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST);
+ return $joins;
+ }
+
+ private function shouldJoinRecipients() {
+ if ($this->recipientPHIDs === null) {
+ return false;
}
- return $joins;
+ return true;
}
protected function getPrimaryTableAlias() {
@@ -134,4 +119,14 @@
return 'PhabricatorMetaMTAApplication';
}
+ protected function shouldGroupQueryResultRows() {
+ if ($this->shouldJoinRecipients()) {
+ if (count($this->recipientPHIDs) > 1) {
+ return true;
+ }
+ }
+
+ return parent::shouldGroupQueryResultRows();
+ }
+
}
diff --git a/src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php
--- a/src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php
+++ b/src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php
@@ -234,7 +234,7 @@
// T11773 for some discussion.
$this->isOverheated = false;
- // See T13386. If we on an old offset-based paging workflow, we need
+ // See T13386. If we are on an old offset-based paging workflow, we need
// to base the overheating limit on both the offset and limit.
$overheat_limit = $need * 10;
$total_seen = 0;

File Metadata

Mime Type
text/plain
Expires
Mon, May 13, 9:57 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6277567
Default Alt Text
D21486.diff (3 KB)

Event Timeline