Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4011511
D25676.1746626072.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
D25676.1746626072.diff
View Options
diff --git a/src/applications/differential/query/DifferentialRevisionQuery.php b/src/applications/differential/query/DifferentialRevisionQuery.php
--- a/src/applications/differential/query/DifferentialRevisionQuery.php
+++ b/src/applications/differential/query/DifferentialRevisionQuery.php
@@ -466,13 +466,25 @@
$basic_authors = $this->authors;
$basic_reviewers = $this->reviewers;
+ // Note that '$this->responsibles' can contain both projects and users,
+ // so let's get only the users.
+ $responsible_users = $this->filterUserPHIDs($this->responsibles);
+
try {
+ // First part of the UNION query:
// Build the query where the responsible users are authors.
- $this->authors = array_merge($basic_authors, $this->responsibles);
-
+ // Special case: skip this first query if it does not have any
+ // condition, because it would just return everything,
+ // and we would generate "(SELECT EVERYTHING) UNION (SELECT SOMETHING)"
+ // and this first nonsense query returning everything would defuse the
+ // next query returning something.
+ $this->authors = array_merge($basic_authors, $responsible_users);
$this->reviewers = $basic_reviewers;
- $selects[] = $this->buildSelectStatement($conn);
+ if (!$this->authors && !$this->reviewers) {
+ $selects[] = $this->buildSelectStatement($conn);
+ }
+ // Second part of the UNION query:
// Build the query where the responsible users are reviewers, or
// projects they are members of are reviewers.
$this->authors = $basic_authors;
@@ -1080,6 +1092,16 @@
return $user_authority + $project_authority + $package_authority;
}
+ /**
+ * Get a list of PHIDs, and return only user PHIDs.
+ * @param array $phids Mixed PHIDs
+ * @return array PHIDs User PHIDs
+ */
+ private function filterUserPHIDs(array $phids): array {
+ $phids_grouped = phid_group_by_type($phids);
+ return idx($phids_grouped, PhabricatorPeopleUserPHIDType::TYPECONST, []);
+ }
+
public function getQueryApplicationClass() {
return PhabricatorDifferentialApplication::class;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, May 7, 13:54 (20 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1514278
Default Alt Text
D25676.1746626072.diff (2 KB)
Attached To
Mode
D25676: DifferentialRevisionQuery: avoid nonsense query comparing r.authorPHID with project PHIDs
Attached
Detach File
Event Timeline
Log In to Comment