Page MenuHomePhabricator

D14492.diff
No OneTemporary

D14492.diff

diff --git a/src/applications/conduit/method/ConduitQueryConduitAPIMethod.php b/src/applications/conduit/method/ConduitQueryConduitAPIMethod.php
--- a/src/applications/conduit/method/ConduitQueryConduitAPIMethod.php
+++ b/src/applications/conduit/method/ConduitQueryConduitAPIMethod.php
@@ -19,20 +19,20 @@
}
protected function execute(ConduitAPIRequest $request) {
- $classes = id(new PhutilClassMapQuery())
- ->setAncestorClass('ConduitAPIMethod')
+ $methods = id(new PhabricatorConduitMethodQuery())
+ ->setViewer($request->getUser())
->execute();
- $names_to_params = array();
- foreach ($classes as $class) {
- $names_to_params[$class->getAPIMethodName()] = array(
- 'description' => $class->getMethodDescription(),
- 'params' => $class->getParamTypes(),
- 'return' => $class->getReturnType(),
+ $map = array();
+ foreach ($methods as $method) {
+ $map[$method->getAPIMethodName()] = array(
+ 'description' => $method->getMethodDescription(),
+ 'params' => $method->getParamTypes(),
+ 'return' => $method->getReturnType(),
);
}
- return $names_to_params;
+ return $map;
}
}
diff --git a/src/applications/conduit/query/PhabricatorConduitMethodQuery.php b/src/applications/conduit/query/PhabricatorConduitMethodQuery.php
--- a/src/applications/conduit/query/PhabricatorConduitMethodQuery.php
+++ b/src/applications/conduit/query/PhabricatorConduitMethodQuery.php
@@ -115,6 +115,43 @@
return $methods;
}
+ protected function willFilterPage(array $methods) {
+ $application_phids = array();
+ foreach ($methods as $method) {
+ $application = $method->getApplication();
+ if ($application === null) {
+ continue;
+ }
+ $application_phids[] = $application->getPHID();
+ }
+
+ if ($application_phids) {
+ $applications = id(new PhabricatorApplicationQuery())
+ ->setParentQuery($this)
+ ->setViewer($this->getViewer())
+ ->withPHIDs($application_phids)
+ ->execute();
+ $applications = mpull($applications, null, 'getPHID');
+ } else {
+ $applications = array();
+ }
+
+ // Remove methods which belong to an application the viewer can not see.
+ foreach ($methods as $key => $method) {
+ $application = $method->getApplication();
+ if ($application === null) {
+ continue;
+ }
+
+ if (empty($applications[$application->getPHID()])) {
+ $this->didRejectResult($method);
+ unset($methods[$key]);
+ }
+ }
+
+ return $methods;
+ }
+
public function getQueryApplicationClass() {
return 'PhabricatorConduitApplication';
}
diff --git a/src/applications/paste/editor/PhabricatorPasteEditEngine.php b/src/applications/paste/editor/PhabricatorPasteEditEngine.php
--- a/src/applications/paste/editor/PhabricatorPasteEditEngine.php
+++ b/src/applications/paste/editor/PhabricatorPasteEditEngine.php
@@ -9,6 +9,10 @@
return pht('Pastes');
}
+ public function getEngineApplicationClass() {
+ return 'PhabricatorPasteApplication';
+ }
+
protected function newEditableObject() {
return PhabricatorPaste::initializeNewPaste($this->getViewer());
}
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -50,6 +50,7 @@
/* -( Managing Fields )---------------------------------------------------- */
+ abstract public function getEngineApplicationClass();
abstract protected function buildCustomEditFields($object);
final protected function buildEditFields($object) {
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php b/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php
@@ -5,6 +5,12 @@
abstract public function newEditEngine();
+ public function getApplication() {
+ $engine = $this->newEditEngine();
+ $class = $engine->getEngineApplicationClass();
+ return PhabricatorApplication::getByClass($class);
+ }
+
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}
diff --git a/src/applications/transactions/editor/PhabricatorEditEngineConfigurationEditEngine.php b/src/applications/transactions/editor/PhabricatorEditEngineConfigurationEditEngine.php
--- a/src/applications/transactions/editor/PhabricatorEditEngineConfigurationEditEngine.php
+++ b/src/applications/transactions/editor/PhabricatorEditEngineConfigurationEditEngine.php
@@ -20,6 +20,10 @@
return pht('Edit Configurations');
}
+ public function getEngineApplicationClass() {
+ return 'PhabricatorTransactionsApplication';
+ }
+
protected function newEditableObject() {
return PhabricatorEditEngineConfiguration::initializeNewConfiguration(
$this->getViewer(),

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 19, 6:45 PM (1 h, 10 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6717522
Default Alt Text
D14492.diff (5 KB)

Event Timeline