From 94d42b6313c4f6f7aa6405e811cbaa6966423f0c Mon Sep 17 00:00:00 2001 From: vrana Date: Fri, 14 Dec 2012 17:08:43 -0800 Subject: [PATCH] Throw on invalid Conduit method parameters Summary: NOTE: This may break stuff. Test Plan: $ echo '{}' | arc call-conduit conduit.ping $ echo '{"x": 1}' | arc call-conduit conduit.ping Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4191 --- src/applications/conduit/call/ConduitCall.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/applications/conduit/call/ConduitCall.php b/src/applications/conduit/call/ConduitCall.php index 612633dc96..ddd3de8ee6 100644 --- a/src/applications/conduit/call/ConduitCall.php +++ b/src/applications/conduit/call/ConduitCall.php @@ -11,14 +11,22 @@ final class ConduitCall { private $method; - private $params; private $request; private $user; public function __construct($method, array $params) { $this->method = $method; - $this->params = $params; $this->handler = $this->buildMethodHandler($method); + + $invalid_params = array_diff_key( + $params, + $this->handler->defineParamTypes()); + if ($invalid_params) { + throw new ConduitException( + "Method '{$method}' doesn't define these parameters: '" . + implode("', '", array_keys($invalid_params)) . "'."); + } + $this->request = new ConduitAPIRequest($params); }