From 926b47ef7096fef2189353afe6c9691bf393eaa8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 12 Sep 2013 14:48:24 -0700 Subject: [PATCH] Call array_unique() in Handle/Object queries Summary: I think the old thing did this, but this makes queries a bit less ridiculous. For example, `secure.phabricator.com` currently issues a query for 664 handles on my task list, but only 73 of them are unique (basically, all the projects plus all the authors). This proably is slightly good for performance, but mostly makes the "Services" tab manageable. Test Plan: Looked at Maniphest and some other pages, saw handles and objects where they were expected to be. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D6959 --- src/applications/phid/query/PhabricatorHandleQuery.php | 4 ++-- src/applications/phid/query/PhabricatorObjectQuery.php | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/applications/phid/query/PhabricatorHandleQuery.php b/src/applications/phid/query/PhabricatorHandleQuery.php index 3cdcfb8e5a..c34fcfd3a0 100644 --- a/src/applications/phid/query/PhabricatorHandleQuery.php +++ b/src/applications/phid/query/PhabricatorHandleQuery.php @@ -3,7 +3,7 @@ final class PhabricatorHandleQuery extends PhabricatorCursorPagedPolicyAwareQuery { - private $phids; + private $phids = array(); public function withPHIDs(array $phids) { $this->phids = $phids; @@ -13,7 +13,7 @@ final class PhabricatorHandleQuery public function loadPage() { $types = PhabricatorPHIDType::getAllTypes(); - $phids = $this->phids; + $phids = array_unique($this->phids); if (!$phids) { return array(); } diff --git a/src/applications/phid/query/PhabricatorObjectQuery.php b/src/applications/phid/query/PhabricatorObjectQuery.php index 94b670ebaa..473f914fdf 100644 --- a/src/applications/phid/query/PhabricatorObjectQuery.php +++ b/src/applications/phid/query/PhabricatorObjectQuery.php @@ -3,8 +3,8 @@ final class PhabricatorObjectQuery extends PhabricatorCursorPagedPolicyAwareQuery { - private $phids; - private $names; + private $phids = array(); + private $names = array(); private $namedResults; @@ -25,7 +25,7 @@ final class PhabricatorObjectQuery $types = PhabricatorPHIDType::getAllTypes(); - $names = $this->names; + $names = array_unique($this->names); $phids = $this->phids; // We allow objects to be named by their PHID in addition to their normal @@ -42,6 +42,8 @@ final class PhabricatorObjectQuery } } + $phids = array_unique($phids); + if ($names) { $name_results = $this->loadObjectsByName($types, $names); } else {