From d73df58cc6c3e00314b44b26a072ea36169a94c9 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 9 Mar 2017 11:32:35 -0800 Subject: [PATCH] Prevent use of the "quality" constraint in the Badge search API Summary: Ref T12270. This just drops the constraint for now, rather than dealing with all the typecasting stuff and putting us in a position which will almost certainly require backward compatibility breaks in the future. Also renames "badges.*" to "badge.*" for consistency (all other methods are singular: token.*, project.*, differential.revision.*, etc). Test Plan: Saw "qualities" now "Not Supported", while other constraints continue to work: {F3887194} Reviewers: chad Reviewed By: chad Maniphest Tasks: T12270 Differential Revision: https://secure.phabricator.com/D17487 --- .../PhabricatorBadgesEditConduitAPIMethod.php | 2 +- .../PhabricatorBadgesSearchConduitAPIMethod.php | 2 +- .../PhabricatorBadgesAwardTestDataGenerator.php | 2 +- .../PhabricatorBadgesBadgeTestDataGenerator.php | 2 +- .../query/PhabricatorBadgesSearchEngine.php | 1 + .../search/field/PhabricatorSearchField.php | 15 +++++++++++++++ 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/applications/badges/conduit/PhabricatorBadgesEditConduitAPIMethod.php b/src/applications/badges/conduit/PhabricatorBadgesEditConduitAPIMethod.php index 42be0c2ba3..2ad0c92d32 100644 --- a/src/applications/badges/conduit/PhabricatorBadgesEditConduitAPIMethod.php +++ b/src/applications/badges/conduit/PhabricatorBadgesEditConduitAPIMethod.php @@ -4,7 +4,7 @@ final class PhabricatorBadgesEditConduitAPIMethod extends PhabricatorEditEngineAPIMethod { public function getAPIMethodName() { - return 'badges.edit'; + return 'badge.edit'; } public function newEditEngine() { diff --git a/src/applications/badges/conduit/PhabricatorBadgesSearchConduitAPIMethod.php b/src/applications/badges/conduit/PhabricatorBadgesSearchConduitAPIMethod.php index 5d9fc9c5aa..e71ee9aa71 100644 --- a/src/applications/badges/conduit/PhabricatorBadgesSearchConduitAPIMethod.php +++ b/src/applications/badges/conduit/PhabricatorBadgesSearchConduitAPIMethod.php @@ -4,7 +4,7 @@ final class PhabricatorBadgesSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { - return 'badges.search'; + return 'badge.search'; } public function newSearchEngine() { diff --git a/src/applications/badges/lipsum/PhabricatorBadgesAwardTestDataGenerator.php b/src/applications/badges/lipsum/PhabricatorBadgesAwardTestDataGenerator.php index ba523a9000..f64a42db83 100644 --- a/src/applications/badges/lipsum/PhabricatorBadgesAwardTestDataGenerator.php +++ b/src/applications/badges/lipsum/PhabricatorBadgesAwardTestDataGenerator.php @@ -26,7 +26,7 @@ final class PhabricatorBadgesAwardTestDataGenerator 'objectIdentifier' => $badge_phid, ); - $result = id(new ConduitCall('badges.edit', $params)) + $result = id(new ConduitCall('badge.edit', $params)) ->setUser($author) ->execute(); diff --git a/src/applications/badges/lipsum/PhabricatorBadgesBadgeTestDataGenerator.php b/src/applications/badges/lipsum/PhabricatorBadgesBadgeTestDataGenerator.php index 8d56e20fa3..8d496c18a1 100644 --- a/src/applications/badges/lipsum/PhabricatorBadgesBadgeTestDataGenerator.php +++ b/src/applications/badges/lipsum/PhabricatorBadgesBadgeTestDataGenerator.php @@ -40,7 +40,7 @@ final class PhabricatorBadgesBadgeTestDataGenerator 'transactions' => $xactions, ); - $result = id(new ConduitCall('badges.edit', $params)) + $result = id(new ConduitCall('badge.edit', $params)) ->setUser($author) ->execute(); diff --git a/src/applications/badges/query/PhabricatorBadgesSearchEngine.php b/src/applications/badges/query/PhabricatorBadgesSearchEngine.php index 4db0cdd979..6e84c30bc9 100644 --- a/src/applications/badges/query/PhabricatorBadgesSearchEngine.php +++ b/src/applications/badges/query/PhabricatorBadgesSearchEngine.php @@ -24,6 +24,7 @@ final class PhabricatorBadgesSearchEngine id(new PhabricatorSearchCheckboxesField()) ->setKey('qualities') ->setLabel(pht('Quality')) + ->setEnableForConduit(false) ->setOptions(PhabricatorBadgesQuality::getDropdownQualityMap()), id(new PhabricatorSearchCheckboxesField()) ->setKey('statuses') diff --git a/src/applications/search/field/PhabricatorSearchField.php b/src/applications/search/field/PhabricatorSearchField.php index 099fbdcc51..1a038ec665 100644 --- a/src/applications/search/field/PhabricatorSearchField.php +++ b/src/applications/search/field/PhabricatorSearchField.php @@ -19,6 +19,8 @@ abstract class PhabricatorSearchField extends Phobject { private $description; private $isHidden; + private $enableForConduit = true; + /* -( Configuring Fields )------------------------------------------------- */ @@ -333,6 +335,10 @@ abstract class PhabricatorSearchField extends Phobject { * @task conduit */ final public function getConduitParameterType() { + if (!$this->getEnableForConduit()) { + return false; + } + $type = $this->newConduitParameterType(); if ($type) { @@ -367,6 +373,15 @@ abstract class PhabricatorSearchField extends Phobject { $this->getConduitKey()); } + final public function setEnableForConduit($enable) { + $this->enableForConduit = $enable; + return $this; + } + + final public function getEnableForConduit() { + return $this->enableForConduit; + } + /* -( Utility Methods )----------------------------------------------------- */