Page MenuHomePhabricator

D10879.id26169.diff
No OneTemporary

D10879.id26169.diff

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 @@
private 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
@@ -54,7 +54,7 @@
$resources = id(new DrydockResourceQuery())
->setParentQuery($this)
->setViewer($this->getViewer())
- ->withIDs($resource_ids)
+ ->withIDs(array_unique($resource_ids))
->execute();
} else {
$resources = array();
@@ -78,35 +78,35 @@
private 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->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->statuses) {
+ if ($this->statuses !== null) {
$where[] = qsprintf(
$conn_r,
'status IN (%Ld)',
$this->statuses);
}
- if ($this->datasourceQuery) {
+ if ($this->datasourceQuery !== null) {
$where[] = qsprintf(
$conn_r,
'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
@@ -42,7 +42,7 @@
$blueprints = id(new DrydockBlueprintQuery())
->setParentQuery($this)
->setViewer($this->getViewer())
- ->withPHIDs($blueprint_phids)
+ ->withPHIDs(array_unique($blueprint_phids))
->execute();
$blueprints = mpull($blueprints, null, 'getPHID');
} else {
@@ -66,7 +66,7 @@
$resources = id(new DrydockResourceQuery())
->setParentQuery($this)
->setViewer($this->getViewer())
- ->withIDs($resource_ids)
+ ->withIDs(array_unique($resource_ids))
->execute();
} else {
$resources = array();
@@ -89,7 +89,7 @@
$leases = id(new DrydockLeaseQuery())
->setParentQuery($this)
->setViewer($this->getViewer())
- ->withIDs($lease_ids)
+ ->withIDs(array_unique($lease_ids))
->execute();
} else {
$leases = array();
@@ -113,21 +113,21 @@
private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
- if ($this->blueprintPHIDs) {
+ if ($this->blueprintPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
'blueprintPHID IN (%Ls)',
$this->blueprintPHIDs);
}
- 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
@@ -27,23 +27,42 @@
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
+ $blueprint_phids = $saved->getParameter('blueprintPHIDs', array());
+ $resource_phids = $saved->getParameter('resourcePHIDs', array());
+ $lease_phids = $saved->getParameter('leasePHIDs', array());
// 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');
+ $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');
+ }
+
+ $query = new DrydockLogQuery();
+ if ($blueprint_phids) {
+ $query->withBlueprintPHIDs($blueprint_phids);
+ }
+ if ($resource_ids) {
+ $query->withResourceIDs($resource_ids);
+ }
+ if ($lease_ids) {
+ $query->withLeaseIDs($lease_ids);
+ }
- return id(new DrydockLogQuery())
- ->withBlueprintPHIDs($saved->getParameter('blueprintPHIDs', array()))
- ->withResourceIDs($resource_ids)
- ->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 @@
private 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

Mime Type
text/plain
Expires
Sun, Mar 16, 6:30 AM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7226258
Default Alt Text
D10879.id26169.diff (7 KB)

Event Timeline