Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15284633
D21486.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D21486.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 5, 10:13 AM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7224976
Default Alt Text
D21486.diff (3 KB)
Attached To
Mode
D21486: Add a missing "GROUP BY" to MailQuery when querying for multiple recipients
Attached
Detach File
Event Timeline
Log In to Comment