Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14354690
D10879.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D10879.diff
View Options
diff --git a/src/applications/drydock/query/DrydockBlueprintQuery.php b/src/applications/drydock/query/DrydockBlueprintQuery.php
--- a/src/applications/drydock/query/DrydockBlueprintQuery.php
+++ b/src/applications/drydock/query/DrydockBlueprintQuery.php
@@ -51,21 +51,21 @@
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
- if ($this->ids) {
+ if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
'id IN (%Ld)',
$this->ids);
}
- if ($this->phids) {
+ if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
'phid IN (%Ls)',
$this->phids);
}
- if ($this->datasourceQuery) {
+ if ($this->datasourceQuery !== null) {
$where[] = qsprintf(
$conn_r,
'blueprintName LIKE %>',
diff --git a/src/applications/drydock/query/DrydockLeaseQuery.php b/src/applications/drydock/query/DrydockLeaseQuery.php
--- a/src/applications/drydock/query/DrydockLeaseQuery.php
+++ b/src/applications/drydock/query/DrydockLeaseQuery.php
@@ -47,7 +47,7 @@
$resources = id(new DrydockResourceQuery())
->setParentQuery($this)
->setViewer($this->getViewer())
- ->withIDs($resource_ids)
+ ->withIDs(array_unique($resource_ids))
->execute();
} else {
$resources = array();
@@ -71,35 +71,35 @@
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
- if ($this->resourceIDs) {
+ if ($this->resourceIDs !== null) {
$where[] = qsprintf(
$conn,
'resourceID IN (%Ld)',
$this->resourceIDs);
}
- if ($this->ids) {
+ if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
'id IN (%Ld)',
$this->ids);
}
- if ($this->phids) {
+ if ($this->phids !== null) {
$where[] = qsprintf(
$conn,
'phid IN (%Ls)',
$this->phids);
}
- if ($this->statuses) {
+ if ($this->statuses !== null) {
$where[] = qsprintf(
$conn,
'status IN (%Ld)',
$this->statuses);
}
- if ($this->datasourceQuery) {
+ if ($this->datasourceQuery !== null) {
$where[] = qsprintf(
$conn,
'id = %d',
diff --git a/src/applications/drydock/query/DrydockLogQuery.php b/src/applications/drydock/query/DrydockLogQuery.php
--- a/src/applications/drydock/query/DrydockLogQuery.php
+++ b/src/applications/drydock/query/DrydockLogQuery.php
@@ -36,7 +36,7 @@
$resources = id(new DrydockResourceQuery())
->setParentQuery($this)
->setViewer($this->getViewer())
- ->withIDs($resource_ids)
+ ->withIDs(array_unique($resource_ids))
->execute();
} else {
$resources = array();
@@ -59,7 +59,7 @@
$leases = id(new DrydockLeaseQuery())
->setParentQuery($this)
->setViewer($this->getViewer())
- ->withIDs($lease_ids)
+ ->withIDs(array_unique($lease_ids))
->execute();
} else {
$leases = array();
@@ -91,14 +91,14 @@
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
- if ($this->resourceIDs) {
+ if ($this->resourceIDs !== null) {
$where[] = qsprintf(
$conn_r,
'resourceID IN (%Ld)',
$this->resourceIDs);
}
- if ($this->leaseIDs) {
+ if ($this->leaseIDs !== null) {
$where[] = qsprintf(
$conn_r,
'leaseID IN (%Ld)',
diff --git a/src/applications/drydock/query/DrydockLogSearchEngine.php b/src/applications/drydock/query/DrydockLogSearchEngine.php
--- a/src/applications/drydock/query/DrydockLogSearchEngine.php
+++ b/src/applications/drydock/query/DrydockLogSearchEngine.php
@@ -24,22 +24,38 @@
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
+ $resource_phids = $saved->getParameter('resourcePHIDs', array());
+ $lease_phids = $saved->getParameter('leasePHIDs', array());
+
+ // TODO: Change logs to use PHIDs instead of IDs.
+ $resource_ids = array();
+ $lease_ids = array();
+
+ if ($resource_phids) {
+ $resource_ids = id(new DrydockResourceQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withPHIDs($resource_phids)
+ ->execute();
+ $resource_ids = mpull($resource_ids, 'getID');
+ }
+
+ if ($lease_phids) {
+ $lease_ids = id(new DrydockLeaseQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withPHIDs($lease_phids)
+ ->execute();
+ $lease_ids = mpull($lease_ids, 'getID');
+ }
- // TODO: Change logs to use PHIDs instead of IDs.
- $resource_ids = id(new DrydockResourceQuery())
- ->setViewer(PhabricatorUser::getOmnipotentUser())
- ->withPHIDs($saved->getParameter('resourcePHIDs', array()))
- ->execute();
- $resource_ids = mpull($resource_ids, 'getID');
- $lease_ids = id(new DrydockLeaseQuery())
- ->setViewer(PhabricatorUser::getOmnipotentUser())
- ->withPHIDs($saved->getParameter('leasePHIDs', array()))
- ->execute();
- $lease_ids = mpull($lease_ids, 'getID');
-
- return id(new DrydockLogQuery())
- ->withResourceIDs($resource_ids)
- ->withLeaseIDs($lease_ids);
+ $query = new DrydockLogQuery();
+ if ($resource_ids) {
+ $query->withResourceIDs($resource_ids);
+ }
+ if ($lease_ids) {
+ $query->withLeaseIDs($lease_ids);
+ }
+
+ return $query;
}
public function buildSearchForm(
diff --git a/src/applications/drydock/query/DrydockResourceQuery.php b/src/applications/drydock/query/DrydockResourceQuery.php
--- a/src/applications/drydock/query/DrydockResourceQuery.php
+++ b/src/applications/drydock/query/DrydockResourceQuery.php
@@ -59,42 +59,42 @@
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
- if ($this->ids) {
+ if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
'id IN (%Ld)',
$this->ids);
}
- if ($this->phids) {
+ if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
'phid IN (%Ls)',
$this->phids);
}
- if ($this->types) {
+ if ($this->types !== null) {
$where[] = qsprintf(
$conn_r,
'type IN (%Ls)',
$this->types);
}
- if ($this->statuses) {
+ if ($this->statuses !== null) {
$where[] = qsprintf(
$conn_r,
'status IN (%Ls)',
$this->statuses);
}
- if ($this->blueprintPHIDs) {
+ if ($this->blueprintPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
'blueprintPHID IN (%Ls)',
$this->blueprintPHIDs);
}
- if ($this->datasourceQuery) {
+ if ($this->datasourceQuery !== null) {
$where[] = qsprintf(
$conn_r,
'name LIKE %>',
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 5:21 PM (4 h, 47 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6910238
Default Alt Text
D10879.diff (6 KB)
Attached To
Mode
D10879: Fix issues where Drydock queries didn't work correctly with empty arrays
Attached
Detach File
Event Timeline
Log In to Comment