From 48806b5e3eeab08cda7b2f183e41eda727841668 Mon Sep 17 00:00:00 2001 From: mkedia Date: Thu, 2 Aug 2012 15:56:42 -0700 Subject: [PATCH] [easy] Add support for fetching all packages to owners.query Summary: as title Test Plan: tested without params. Tested with single known path Reviewers: epriestley, vrana, nh Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3139 --- .../owners/ConduitAPI_owners_query_Method.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/applications/conduit/method/owners/ConduitAPI_owners_query_Method.php b/src/applications/conduit/method/owners/ConduitAPI_owners_query_Method.php index ae6b3e81e4..2d784fa3be 100644 --- a/src/applications/conduit/method/owners/ConduitAPI_owners_query_Method.php +++ b/src/applications/conduit/method/owners/ConduitAPI_owners_query_Method.php @@ -54,6 +54,10 @@ final class ConduitAPI_owners_query_Method ); } + protected static function queryAll() { + return id(new PhabricatorOwnersPackage())->loadAll(); + } + protected static function queryByOwner($owner) { $is_valid_phid = phid_get_type($owner) == PhabricatorPHIDConstants::PHID_TYPE_USER || @@ -152,8 +156,11 @@ final class ConduitAPI_owners_query_Method $path = $request->getValue('path'); $is_path_query = ($repo && $path) ? 1 : 0; - // exactly one of these should be provided - if ($is_owner_query + $is_path_query + $is_affiliated_query !== 1) { + if ($is_owner_query + $is_path_query + $is_affiliated_query === 0) { + // if no search terms are provided, return everything + $packages = self::queryAll(); + } else if ($is_owner_query + $is_path_query + $is_affiliated_query > 1) { + // otherwise, exactly one of these should be provided throw new ConduitException('ERR-INVALID-USAGE'); } @@ -168,7 +175,7 @@ final class ConduitAPI_owners_query_Method $packages = self::queryByOwner($owner); - } else { + } else if ($is_path_query) { $packages = self::queryByPath($repo, $path); }