Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15453365
D21384.id50909.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D21384.id50909.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -126,7 +126,7 @@
'ArcanistComprehensiveLintEngine' => 'lint/engine/ArcanistComprehensiveLintEngine.php',
'ArcanistConcatenationOperatorXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistConcatenationOperatorXHPASTLinterRule.php',
'ArcanistConcatenationOperatorXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistConcatenationOperatorXHPASTLinterRuleTestCase.php',
- 'ArcanistConduitCall' => 'conduit/ArcanistConduitCall.php',
+ 'ArcanistConduitCallFuture' => 'conduit/ArcanistConduitCallFuture.php',
'ArcanistConduitEngine' => 'conduit/ArcanistConduitEngine.php',
'ArcanistConduitException' => 'conduit/ArcanistConduitException.php',
'ArcanistConfigOption' => 'config/option/ArcanistConfigOption.php',
@@ -1170,7 +1170,7 @@
'ArcanistComprehensiveLintEngine' => 'ArcanistLintEngine',
'ArcanistConcatenationOperatorXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistConcatenationOperatorXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
- 'ArcanistConduitCall' => 'Phobject',
+ 'ArcanistConduitCallFuture' => 'FutureProxy',
'ArcanistConduitEngine' => 'Phobject',
'ArcanistConduitException' => 'Exception',
'ArcanistConfigOption' => 'Phobject',
diff --git a/src/conduit/ArcanistConduitCall.php b/src/conduit/ArcanistConduitCallFuture.php
rename from src/conduit/ArcanistConduitCall.php
rename to src/conduit/ArcanistConduitCallFuture.php
--- a/src/conduit/ArcanistConduitCall.php
+++ b/src/conduit/ArcanistConduitCallFuture.php
@@ -1,22 +1,9 @@
<?php
-final class ArcanistConduitCall
- extends Phobject {
+final class ArcanistConduitCallFuture
+ extends FutureProxy {
- private $key;
private $engine;
- private $method;
- private $parameters;
- private $future;
-
- public function setKey($key) {
- $this->key = $key;
- return $this;
- }
-
- public function getKey() {
- return $this->key;
- }
public function setEngine(ArcanistConduitEngine $engine) {
$this->engine = $engine;
@@ -27,71 +14,6 @@
return $this->engine;
}
- public function setMethod($method) {
- $this->method = $method;
- return $this;
- }
-
- public function getMethod() {
- return $this->method;
- }
-
- public function setParameters(array $parameters) {
- $this->parameters = $parameters;
- return $this;
- }
-
- public function getParameters() {
- return $this->parameters;
- }
-
- private function newFuture() {
- if ($this->future) {
- throw new Exception(
- pht(
- 'Call has previously generated a future. Create a '.
- 'new call object for each API method invocation.'));
- }
-
- $method = $this->getMethod();
- $parameters = $this->getParameters();
- $future = $this->getEngine()->newFuture($this);
- $this->future = $future;
-
- return $this->future;
- }
-
- public function resolve() {
- if (!$this->future) {
- $this->newFuture();
- }
-
- return $this->resolveFuture();
- }
-
- private function resolveFuture() {
- $future = $this->future;
-
- try {
- $result = $future->resolve();
- } catch (ConduitClientException $ex) {
- switch ($ex->getErrorCode()) {
- case 'ERR-INVALID-SESSION':
- if (!$this->getEngine()->getConduitToken()) {
- $this->raiseLoginRequired();
- }
- break;
- case 'ERR-INVALID-AUTH':
- $this->raiseInvalidAuth();
- break;
- }
-
- throw $ex;
- }
-
- return $result;
- }
-
private function raiseLoginRequired() {
$conduit_uri = $this->getEngine()->getConduitURI();
$conduit_uri = new PhutilURI($conduit_uri);
@@ -119,7 +41,7 @@
" $ arc install-certificate %s\n",
$conduit_uri));
- throw new ArcanistUsageException($block->drawConsoleString());
+ throw new PhutilArgumentUsageException($block->drawConsoleString());
}
private function raiseInvalidAuth() {
@@ -147,7 +69,26 @@
" $ arc install-certificate %s\n",
$conduit_uri));
- throw new ArcanistUsageException($block->drawConsoleString());
+ throw new PhutilArgumentUsageException($block->drawConsoleString());
+ }
+
+ protected function didReceiveResult($result) {
+ return $result;
+ }
+
+ protected function didReceiveException($exception) {
+ switch ($exception->getErrorCode()) {
+ case 'ERR-INVALID-SESSION':
+ if (!$this->getEngine()->getConduitToken()) {
+ $this->raiseLoginRequired();
+ }
+ break;
+ case 'ERR-INVALID-AUTH':
+ $this->raiseInvalidAuth();
+ break;
+ }
+
+ throw $exception;
}
}
diff --git a/src/conduit/ArcanistConduitEngine.php b/src/conduit/ArcanistConduitEngine.php
--- a/src/conduit/ArcanistConduitEngine.php
+++ b/src/conduit/ArcanistConduitEngine.php
@@ -39,28 +39,17 @@
return $this->conduitTimeout;
}
- public function newCall($method, array $parameters) {
+ public function newFuture($method, array $parameters) {
if ($this->conduitURI == null && $this->client === null) {
$this->raiseURIException();
}
- return id(new ArcanistConduitCall())
- ->setEngine($this)
- ->setMethod($method)
- ->setParameters($parameters);
- }
-
- public function resolveCall($method, array $parameters) {
- return $this->newCall($method, $parameters)->resolve();
- }
-
- public function newFuture(ArcanistConduitCall $call) {
- $method = $call->getMethod();
- $parameters = $call->getParameters();
-
$future = $this->getClient()->callMethod($method, $parameters);
- return $future;
+ $call_future = id(new ArcanistConduitCallFuture($future))
+ ->setEngine($this);
+
+ return $call_future;
}
private function getClient() {
diff --git a/src/conduit/ConduitSearchFuture.php b/src/conduit/ConduitSearchFuture.php
--- a/src/conduit/ConduitSearchFuture.php
+++ b/src/conduit/ConduitSearchFuture.php
@@ -104,8 +104,7 @@
$parameters['after'] = (string)$this->cursor;
}
- $conduit_call = $engine->newCall($method, $parameters);
- $conduit_future = $engine->newFuture($conduit_call);
+ $conduit_future = $engine->newFuture($method, $parameters);
return $conduit_future;
}
diff --git a/src/ref/paste/ArcanistPasteRef.php b/src/ref/paste/ArcanistPasteRef.php
--- a/src/ref/paste/ArcanistPasteRef.php
+++ b/src/ref/paste/ArcanistPasteRef.php
@@ -48,7 +48,7 @@
protected function buildRefView(ArcanistRefView $view) {
$view
->setObjectName($this->getMonogram())
- ->setTitle($this->getName());
+ ->setTitle($this->getTitle());
}
}
diff --git a/src/toolset/query/ArcanistRuntimeHardpointQuery.php b/src/toolset/query/ArcanistRuntimeHardpointQuery.php
--- a/src/toolset/query/ArcanistRuntimeHardpointQuery.php
+++ b/src/toolset/query/ArcanistRuntimeHardpointQuery.php
@@ -77,8 +77,7 @@
$conduit_engine = $this->getRuntime()
->getConduitEngine();
- $call_object = $conduit_engine->newCall($method, $parameters);
- $call_future = $conduit_engine->newFuture($call_object);
+ $call_future = $conduit_engine->newFuture($method, $parameters);
return $call_future;
}
diff --git a/src/upload/ArcanistFileUploader.php b/src/upload/ArcanistFileUploader.php
--- a/src/upload/ArcanistFileUploader.php
+++ b/src/upload/ArcanistFileUploader.php
@@ -118,11 +118,7 @@
$params['deleteAfterEpoch'] = $delete_after;
}
- // TOOLSETS: This should be a real future, but ConduitEngine and
- // ConduitCall are currently built oddly and return pretend futures.
-
- $futures[$key] = new ImmediateFuture(
- $conduit->resolveCall('file.allocate', $params));
+ $futures[$key] = $conduit->newFuture('file.allocate', $params);
}
$iterator = id(new FutureIterator($futures))->limit(4);
@@ -217,11 +213,12 @@
private function uploadChunks(ArcanistFileDataRef $file, $file_phid) {
$conduit = $this->conduitEngine;
- $chunks = $conduit->resolveCall(
+ $future = $conduit->newFuture(
'file.querychunks',
array(
'filePHID' => $file_phid,
));
+ $chunks = $future->resolve();
$remaining = array();
foreach ($chunks as $chunk) {
@@ -258,7 +255,7 @@
foreach ($remaining as $chunk) {
$data = $file->readBytes($chunk['byteStart'], $chunk['byteEnd']);
- $conduit->resolveCall(
+ $future = $conduit->newFuture(
'file.uploadchunk',
array(
'filePHID' => $file_phid,
@@ -266,6 +263,7 @@
'dataEncoding' => 'base64',
'data' => base64_encode($data),
));
+ $future->resolve();
$progress->update(1);
}
@@ -282,11 +280,13 @@
$data = $file->readBytes(0, $file->getByteSize());
- return $conduit->resolveCall(
+ $future = $conduit->newFuture(
'file.upload',
$this->getUploadParameters($file) + array(
'data_base64' => base64_encode($data),
));
+
+ return $future->resolve();
}
diff --git a/src/workflow/ArcanistCallConduitWorkflow.php b/src/workflow/ArcanistCallConduitWorkflow.php
--- a/src/workflow/ArcanistCallConduitWorkflow.php
+++ b/src/workflow/ArcanistCallConduitWorkflow.php
@@ -53,8 +53,7 @@
}
$engine = $this->getConduitEngine();
- $conduit_call = $engine->newCall($method, $params);
- $conduit_future = $engine->newFuture($conduit_call);
+ $conduit_future = $engine->newFuture($method, $params);
$error = null;
$error_message = null;
diff --git a/src/workflow/ArcanistPasteWorkflow.php b/src/workflow/ArcanistPasteWorkflow.php
--- a/src/workflow/ArcanistPasteWorkflow.php
+++ b/src/workflow/ArcanistPasteWorkflow.php
@@ -141,8 +141,7 @@
);
$conduit_engine = $this->getConduitEngine();
- $conduit_call = $conduit_engine->newCall($method, $parameters);
- $conduit_future = $conduit_engine->newFuture($conduit_call);
+ $conduit_future = $conduit_engine->newFuture($method, $parameters);
$result = $conduit_future->resolve();
$paste_phid = idxv($result, array('object', 'phid'));
diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php
--- a/src/workflow/ArcanistWorkflow.php
+++ b/src/workflow/ArcanistWorkflow.php
@@ -1808,22 +1808,6 @@
return $parser;
}
- final protected function resolveCall(ConduitFuture $method) {
- try {
- return $method->resolve();
- } catch (ConduitClientException $ex) {
- if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') {
- echo phutil_console_wrap(
- pht(
- 'This feature requires a newer version of Phabricator. Please '.
- 'update it using these instructions: %s',
- 'https://secure.phabricator.com/book/phabricator/article/'.
- 'upgrading/')."\n\n");
- }
- throw $ex;
- }
- }
-
final protected function dispatchEvent($type, array $data) {
$data += array(
'workflow' => $this,
@@ -1964,7 +1948,8 @@
try {
$method = 'repository.query';
- $results = $this->getConduitEngine()->newCall($method, $query)
+ $results = $this->getConduitEngine()
+ ->newFuture($method, $query)
->resolve();
} catch (ConduitClientException $ex) {
if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 30, 11:14 AM (4 d, 8 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7395185
Default Alt Text
D21384.id50909.diff (11 KB)
Attached To
Mode
D21384: Implement Conduit login prompt behavior as a pure FutureProxy, not a Future-like object
Attached
Detach File
Event Timeline
Log In to Comment