diff --git a/src/applications/conduit/controller/PhabricatorConduitConsoleController.php b/src/applications/conduit/controller/PhabricatorConduitConsoleController.php index e570861f29..e878365acb 100644 --- a/src/applications/conduit/controller/PhabricatorConduitConsoleController.php +++ b/src/applications/conduit/controller/PhabricatorConduitConsoleController.php @@ -19,6 +19,8 @@ final class PhabricatorConduitConsoleController return new Aphront404Response(); } + $method->setViewer($viewer); + $call_uri = '/api/'.$method->getAPIMethodName(); $status = $method->getMethodStatus(); diff --git a/src/applications/conduit/method/ConduitAPIMethod.php b/src/applications/conduit/method/ConduitAPIMethod.php index afa75c53b3..8471ac8919 100644 --- a/src/applications/conduit/method/ConduitAPIMethod.php +++ b/src/applications/conduit/method/ConduitAPIMethod.php @@ -9,6 +9,7 @@ abstract class ConduitAPIMethod extends Phobject implements PhabricatorPolicyInterface { + private $viewer; const METHOD_STATUS_STABLE = 'stable'; const METHOD_STATUS_UNSTABLE = 'unstable'; @@ -46,8 +47,6 @@ abstract class ConduitAPIMethod abstract protected function execute(ConduitAPIRequest $request); - public function __construct() {} - public function getParamTypes() { $types = $this->defineParamTypes(); @@ -110,6 +109,8 @@ abstract class ConduitAPIMethod } public function executeMethod(ConduitAPIRequest $request) { + $this->setViewer($request->getUser()); + return $this->execute($request); } @@ -211,6 +212,15 @@ abstract class ConduitAPIMethod return null; } + final public function setViewer(PhabricatorUser $viewer) { + $this->viewer = $viewer; + return $this; + } + + final public function getViewer() { + return $this->viewer; + } + /* -( Paging Results )----------------------------------------------------- */ diff --git a/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php b/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php index ae27cb07c0..1ef3e02f33 100644 --- a/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php +++ b/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php @@ -39,8 +39,7 @@ abstract class PhabricatorSearchEngineAPIMethod } final public function getMethodDescription() { - // TODO: We don't currently have a real viewer in this method. - $viewer = PhabricatorUser::getOmnipotentUser(); + $viewer = $this->getViewer(); $engine = $this->newSearchEngine() ->setViewer($viewer); @@ -76,7 +75,8 @@ it like this: } ``` -These builtin and saved queries are available: +You can use these keys to select builtin queries and your configured saved +queries: EOTEXT ); diff --git a/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php b/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php index 8c7fafdc2a..344f22b3c4 100644 --- a/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php +++ b/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php @@ -38,8 +38,7 @@ abstract class PhabricatorEditEngineAPIMethod } final public function getMethodDescription() { - // TODO: We don't currently have a real viewer in this method. - $viewer = PhabricatorUser::getOmnipotentUser(); + $viewer = $this->getViewer(); $engine = $this->newEditEngine() ->setViewer($viewer);