@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Have EditEngine API methods provide the correct application to Conduit

Summary:
Fixes T9799. Currently, if you can't see an application like Paste, we fatal when trying to generate a result for `conduit.query`, because the new EditEngine-based `paste.edit` method doesn't "know" that it's a "Paste" method.

Straighten this out, and use policies and queries a little more correctly/consistently.

Test Plan:
- Called `conduit.query` as a user who does not have permission to use Paste.
- Before change: fatal.
- After change: results, excluding "paste.*" methods.

Reviewers: chad

Reviewed By: chad

Subscribers: cburroughs

Maniphest Tasks: T9799

Differential Revision: https://secure.phabricator.com/D14492

+61 -9
+9 -9
src/applications/conduit/method/ConduitQueryConduitAPIMethod.php
··· 19 19 } 20 20 21 21 protected function execute(ConduitAPIRequest $request) { 22 - $classes = id(new PhutilClassMapQuery()) 23 - ->setAncestorClass('ConduitAPIMethod') 22 + $methods = id(new PhabricatorConduitMethodQuery()) 23 + ->setViewer($request->getUser()) 24 24 ->execute(); 25 25 26 - $names_to_params = array(); 27 - foreach ($classes as $class) { 28 - $names_to_params[$class->getAPIMethodName()] = array( 29 - 'description' => $class->getMethodDescription(), 30 - 'params' => $class->getParamTypes(), 31 - 'return' => $class->getReturnType(), 26 + $map = array(); 27 + foreach ($methods as $method) { 28 + $map[$method->getAPIMethodName()] = array( 29 + 'description' => $method->getMethodDescription(), 30 + 'params' => $method->getParamTypes(), 31 + 'return' => $method->getReturnType(), 32 32 ); 33 33 } 34 34 35 - return $names_to_params; 35 + return $map; 36 36 } 37 37 38 38 }
+37
src/applications/conduit/query/PhabricatorConduitMethodQuery.php
··· 115 115 return $methods; 116 116 } 117 117 118 + protected function willFilterPage(array $methods) { 119 + $application_phids = array(); 120 + foreach ($methods as $method) { 121 + $application = $method->getApplication(); 122 + if ($application === null) { 123 + continue; 124 + } 125 + $application_phids[] = $application->getPHID(); 126 + } 127 + 128 + if ($application_phids) { 129 + $applications = id(new PhabricatorApplicationQuery()) 130 + ->setParentQuery($this) 131 + ->setViewer($this->getViewer()) 132 + ->withPHIDs($application_phids) 133 + ->execute(); 134 + $applications = mpull($applications, null, 'getPHID'); 135 + } else { 136 + $applications = array(); 137 + } 138 + 139 + // Remove methods which belong to an application the viewer can not see. 140 + foreach ($methods as $key => $method) { 141 + $application = $method->getApplication(); 142 + if ($application === null) { 143 + continue; 144 + } 145 + 146 + if (empty($applications[$application->getPHID()])) { 147 + $this->didRejectResult($method); 148 + unset($methods[$key]); 149 + } 150 + } 151 + 152 + return $methods; 153 + } 154 + 118 155 public function getQueryApplicationClass() { 119 156 return 'PhabricatorConduitApplication'; 120 157 }
+4
src/applications/paste/editor/PhabricatorPasteEditEngine.php
··· 9 9 return pht('Pastes'); 10 10 } 11 11 12 + public function getEngineApplicationClass() { 13 + return 'PhabricatorPasteApplication'; 14 + } 15 + 12 16 protected function newEditableObject() { 13 17 return PhabricatorPaste::initializeNewPaste($this->getViewer()); 14 18 }
+1
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 50 50 /* -( Managing Fields )---------------------------------------------------- */ 51 51 52 52 53 + abstract public function getEngineApplicationClass(); 53 54 abstract protected function buildCustomEditFields($object); 54 55 55 56 final protected function buildEditFields($object) {
+6
src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php
··· 5 5 6 6 abstract public function newEditEngine(); 7 7 8 + public function getApplication() { 9 + $engine = $this->newEditEngine(); 10 + $class = $engine->getEngineApplicationClass(); 11 + return PhabricatorApplication::getByClass($class); 12 + } 13 + 8 14 public function getMethodStatus() { 9 15 return self::METHOD_STATUS_UNSTABLE; 10 16 }
+4
src/applications/transactions/editor/PhabricatorEditEngineConfigurationEditEngine.php
··· 20 20 return pht('Edit Configurations'); 21 21 } 22 22 23 + public function getEngineApplicationClass() { 24 + return 'PhabricatorTransactionsApplication'; 25 + } 26 + 23 27 protected function newEditableObject() { 24 28 return PhabricatorEditEngineConfiguration::initializeNewConfiguration( 25 29 $this->getViewer(),