Page MenuHomePhorge

No OneTemporary

diff --git a/src/applications/conduit/controller/base/PhabricatorConduitController.php b/src/applications/conduit/controller/base/PhabricatorConduitController.php
index e8970994f1..8f5988e6f5 100644
--- a/src/applications/conduit/controller/base/PhabricatorConduitController.php
+++ b/src/applications/conduit/controller/base/PhabricatorConduitController.php
@@ -1,125 +1,152 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
abstract class PhabricatorConduitController extends PhabricatorController {
private $filter;
protected $showSideNav;
public function buildStandardPageResponse($view, array $data) {
$doclink = PhabricatorEnv::getDoclink(
'article/Conduit_Technical_Documentation.html'
);
$page = $this->buildStandardPageView();
$page->setApplicationName('Conduit');
$page->setBaseURI('/conduit/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x87\xB5");
$page->setTabs(array(
'help' => array(
'href' => $doclink,
'name' => 'Help')
), null);
if ($this->showSideNav()) {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/conduit/'));
$first_filter = null;
$method_filters = $this->getMethodFilters();
foreach ($method_filters as $group => $methods) {
$nav->addLabel($group);
foreach ($methods as $method) {
$method_name = $method['full_name'];
+
+ $display_name = $method_name;
+ switch ($method['status']) {
+ case ConduitAPIMethod::METHOD_STATUS_DEPRECATED:
+ $display_name = '('.$display_name.')';
+ break;
+ }
+
$nav->addFilter('method/'.$method_name,
- $method_name);
+ $display_name);
if (!$first_filter) {
$first_filter = 'method/'.$method_name;
}
}
$nav->addSpacer();
}
$nav->addLabel('Utilities');
$nav->addFilter('log', 'Logs');
$nav->addFilter('token', 'Token');
$nav->selectFilter($this->getFilter(), $first_filter);
$nav->appendChild($view);
$body = $nav;
} else {
$body = $view;
}
$page->appendChild($body);
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
}
private function getFilter() {
return $this->filter;
}
protected function setFilter($filter) {
$this->filter = $filter;
return $this;
}
private function showSideNav() {
return $this->showSideNav !== false;
}
protected function setShowSideNav($show_side_nav) {
$this->showSideNav = $show_side_nav;
return $this;
}
protected function getAllMethodImplementationClasses() {
$classes = id(new PhutilSymbolLoader())
->setAncestorClass('ConduitAPIMethod')
->setType('class')
->setConcreteOnly(true)
->selectSymbolsWithoutLoading();
return array_values(ipull($classes, 'name'));
}
-
private function getMethodFilters() {
$classes = $this->getAllMethodImplementationClasses();
$method_names = array();
foreach ($classes as $method_class) {
$method_name = ConduitAPIMethod::getAPIMethodNameFromClassName(
$method_class);
- $parts = explode('.', $method_name);
- $method_names[] = array(
+ $group_name = head(explode('.', $method_name));
+
+ $status = newv($method_class, array())->getMethodStatus();
+
+ $key = sprintf(
+ '%02d %s %s',
+ $this->getOrderForMethodStatus($status),
+ $group_name,
+ $method_name);
+
+ $method_names[$key] = array(
'full_name' => $method_name,
- 'group_name' => reset($parts),
+ 'group_name' => $group_name,
+ 'status' => $status,
);
}
+ ksort($method_names);
$method_names = igroup($method_names, 'group_name');
ksort($method_names);
return $method_names;
}
+ private function getOrderForMethodStatus($status) {
+ $map = array(
+ ConduitAPIMethod::METHOD_STATUS_STABLE => 0,
+ ConduitAPIMethod::METHOD_STATUS_UNSTABLE => 1,
+ ConduitAPIMethod::METHOD_STATUS_DEPRECATED => 2,
+ );
+ return idx($map, $status, 0);
+ }
+
}
diff --git a/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php b/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php
index ab945a3a82..b1e8a8856d 100644
--- a/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php
+++ b/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php
@@ -1,128 +1,157 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
final class PhabricatorConduitConsoleController
extends PhabricatorConduitController {
private $method;
public function willProcessRequest(array $data) {
$this->method = idx($data, 'method');
}
public function processRequest() {
$request = $this->getRequest();
$methods = $this->getAllMethods();
if (empty($methods[$this->method])) {
$this->method = head_key($methods);
}
$this->setFilter('method/'.$this->method);
$method_class = $methods[$this->method];
- PhutilSymbolLoader::loadClass($method_class);
$method_object = newv($method_class, array());
+ $status = $method_object->getMethodStatus();
+ $reason = $method_object->getMethodStatusDescription();
+
+ $status_view = null;
+ if ($status != 'stable') {
+ $status_view = new AphrontErrorView();
+ switch ($status) {
+ case ConduitAPIMethod::METHOD_STATUS_DEPRECATED:
+ $status_view->setTitle('Deprecated Method');
+ $status_view->appendChild(
+ phutil_escape_html(
+ nonempty(
+ $reason,
+ "This method is deprecated.")));
+ break;
+ case ConduitAPIMethod::METHOD_STATUS_UNSTABLE:
+ $status_view->setSeverity(AphrontErrorView::SEVERITY_WARNING);
+ $status_view->setTitle('Unstable Method');
+ $status_view->appendChild(
+ phutil_escape_html(
+ nonempty(
+ $reason,
+ "This method is new and unstable. Its interface is subject ".
+ "to change.")));
+ break;
+ }
+ }
$error_description = array();
$error_types = $method_object->defineErrorTypes();
if ($error_types) {
$error_description[] = '<ul>';
foreach ($error_types as $error => $meaning) {
$error_description[] =
'<li>'.
'<strong>'.phutil_escape_html($error).':</strong> '.
phutil_escape_html($meaning).
'</li>';
}
$error_description[] = '</ul>';
$error_description = implode("\n", $error_description);
} else {
$error_description = "This method does not raise any specific errors.";
}
$form = new AphrontFormView();
$form
->setUser($request->getUser())
->setAction('/api/'.$this->method)
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Description')
->setValue($method_object->getMethodDescription()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Returns')
->setValue($method_object->defineReturnType()))
->appendChild(
id(new AphrontFormMarkupControl())
->setLabel('Errors')
->setValue($error_description))
->appendChild(
'<p class="aphront-form-instructions">Enter parameters using '.
'<strong>JSON</strong>. For instance, to enter a list, type: '.
'<tt>["apple", "banana", "cherry"]</tt>');
$params = $method_object->defineParamTypes();
foreach ($params as $param => $desc) {
$form->appendChild(
id(new AphrontFormTextControl())
->setLabel($param)
->setName("params[{$param}]")
->setCaption(phutil_escape_html($desc)));
}
$form
->appendChild(
id(new AphrontFormSelectControl())
->setLabel('Output Format')
->setName('output')
->setOptions(
array(
'human' => 'Human Readable',
'json' => 'JSON',
)))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Call Method'));
$panel = new AphrontPanelView();
$panel->setHeader('Conduit API: '.phutil_escape_html($this->method));
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
return $this->buildStandardPageResponse(
- array($panel),
+ array(
+ $status_view,
+ $panel,
+ ),
array(
'title' => 'Conduit Console',
));
}
private function getAllMethods() {
$classes = $this->getAllMethodImplementationClasses();
$methods = array();
foreach ($classes as $class) {
$name = ConduitAPIMethod::getAPIMethodNameFromClassName($class);
$methods[$name] = $class;
}
return $methods;
}
}
diff --git a/src/applications/conduit/controller/console/__init__.php b/src/applications/conduit/controller/console/__init__.php
index f58e4210cc..5e21a1df74 100644
--- a/src/applications/conduit/controller/console/__init__.php
+++ b/src/applications/conduit/controller/console/__init__.php
@@ -1,24 +1,24 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/conduit/controller/base');
phutil_require_module('phabricator', 'applications/conduit/method/base');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/markup');
phutil_require_module('phabricator', 'view/form/control/select');
phutil_require_module('phabricator', 'view/form/control/static');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/form/control/text');
+phutil_require_module('phabricator', 'view/form/error');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'markup');
-phutil_require_module('phutil', 'symbols');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorConduitConsoleController.php');
diff --git a/src/applications/conduit/method/base/ConduitAPIMethod.php b/src/applications/conduit/method/base/ConduitAPIMethod.php
index 04aef555d1..9d30f71073 100644
--- a/src/applications/conduit/method/base/ConduitAPIMethod.php
+++ b/src/applications/conduit/method/base/ConduitAPIMethod.php
@@ -1,107 +1,137 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
+ *
+ * @task status Method Status
* @group conduit
*/
abstract class ConduitAPIMethod {
+ const METHOD_STATUS_STABLE = 'stable';
+ const METHOD_STATUS_UNSTABLE = 'unstable';
+ const METHOD_STATUS_DEPRECATED = 'deprecated';
+
abstract public function getMethodDescription();
abstract public function defineParamTypes();
abstract public function defineReturnType();
abstract public function defineErrorTypes();
abstract protected function execute(ConduitAPIRequest $request);
public function __construct() {
}
+ /**
+ * Get the status for this method (e.g., stable, unstable or deprecated).
+ * Should return a METHOD_STATUS_* constant. By default, methods are
+ * "stable".
+ *
+ * @return const METHOD_STATUS_* constant.
+ * @task status
+ */
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_STABLE;
+ }
+
+ /**
+ * Optional description to supplement the method status. In particular, if
+ * a method is deprecated, you can return a string here describing the reason
+ * for deprecation and stable alternatives.
+ *
+ * @return string|null Description of the method status, if available.
+ * @task status
+ */
+ public function getMethodStatusDescription() {
+ return null;
+ }
+
public function getErrorDescription($error_code) {
return idx($this->defineErrorTypes(), $error_code, 'Unknown Error');
}
public function getRequiredScope() {
// by default, conduit methods are not accessible via OAuth
return PhabricatorOAuthServerScope::SCOPE_NOT_ACCESSIBLE;
}
public function executeMethod(ConduitAPIRequest $request) {
return $this->execute($request);
}
public function getAPIMethodName() {
return self::getAPIMethodNameFromClassName(get_class($this));
}
public static function getClassNameFromAPIMethodName($method_name) {
$method_fragment = str_replace('.', '_', $method_name);
return 'ConduitAPI_'.$method_fragment.'_Method';
}
public function shouldRequireAuthentication() {
return true;
}
public function shouldAllowUnguardedWrites() {
return false;
}
public static function getAPIMethodNameFromClassName($class_name) {
$match = null;
$is_valid = preg_match(
'/^ConduitAPI_(.*)_Method$/',
$class_name,
$match);
if (!$is_valid) {
throw new Exception(
"Parameter '{$class_name}' is not a valid Conduit API method class.");
}
$method_fragment = $match[1];
return str_replace('_', '.', $method_fragment);
}
protected function validateHost($host) {
if (!$host) {
// If the client doesn't send a host key, don't complain. We should in
// the future, but this change isn't severe enough to bump the protocol
// version.
// TODO: Remove this once the protocol version gets bumped past 2 (i.e.,
// require the host key be present and valid).
return;
}
// NOTE: Compare domains only so we aren't sensitive to port specification
// or omission.
$host = new PhutilURI($host);
$host = $host->getDomain();
$self = new PhutilURI(PhabricatorEnv::getURI('/'));
$self = $self->getDomain();
if ($self !== $host) {
throw new Exception(
"Your client is connecting to this install as '{$host}', but it is ".
"configured as '{$self}'. The client and server must use the exact ".
"same URI to identify the install. Edit your .arcconfig or ".
"phabricator/conf so they agree on the URI for the install.");
}
}
}
diff --git a/src/applications/conduit/method/chatlog/query/ConduitAPI_chatlog_query_Method.php b/src/applications/conduit/method/chatlog/query/ConduitAPI_chatlog_query_Method.php
index a434d63196..8bca00e9d0 100644
--- a/src/applications/conduit/method/chatlog/query/ConduitAPI_chatlog_query_Method.php
+++ b/src/applications/conduit/method/chatlog/query/ConduitAPI_chatlog_query_Method.php
@@ -1,76 +1,80 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
final class ConduitAPI_chatlog_query_Method
extends ConduitAPI_chatlog_Method {
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_UNSTABLE;
+ }
+
public function getMethodDescription() {
- return "(Unstable!) Retrieve chatter.";
+ return "Retrieve chatter.";
}
public function defineParamTypes() {
return array(
'channels' => 'optional list<string>',
'limit' => 'optional int (default = 100)',
);
}
public function defineReturnType() {
return 'nonempty list<dict>';
}
public function defineErrorTypes() {
return array();
}
protected function execute(ConduitAPIRequest $request) {
$query = new PhabricatorChatLogQuery();
$channels = $request->getValue('channels');
if ($channels) {
$query->withChannels($channels);
}
$limit = $request->getValue('limit');
if (!$limit) {
$limit = 100;
}
$query->setLimit($limit);
$logs = $query->execute();
$results = array();
foreach ($logs as $log) {
$results[] = array(
'channel' => $log->getChannel(),
'epoch' => $log->getEpoch(),
'author' => $log->getAuthor(),
'type' => $log->getType(),
'message' => $log->getMessage(),
'loggedByPHID' => $log->getLoggedByPHID(),
);
}
return $results;
}
}
diff --git a/src/applications/conduit/method/chatlog/record/ConduitAPI_chatlog_record_Method.php b/src/applications/conduit/method/chatlog/record/ConduitAPI_chatlog_record_Method.php
index 22595322a1..687dee8fb8 100644
--- a/src/applications/conduit/method/chatlog/record/ConduitAPI_chatlog_record_Method.php
+++ b/src/applications/conduit/method/chatlog/record/ConduitAPI_chatlog_record_Method.php
@@ -1,69 +1,73 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
final class ConduitAPI_chatlog_record_Method
extends ConduitAPI_chatlog_Method {
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_UNSTABLE;
+ }
+
public function getMethodDescription() {
- return "(Unstable!) Record chatter.";
+ return "Record chatter.";
}
public function defineParamTypes() {
return array(
'logs' => 'required list<dict>',
);
}
public function defineReturnType() {
return 'list<id>';
}
public function defineErrorTypes() {
return array(
);
}
protected function execute(ConduitAPIRequest $request) {
$logs = $request->getValue('logs');
if (!is_array($logs)) {
$logs = array();
}
$template = new PhabricatorChatLogEvent();
$template->setLoggedByPHID($request->getUser()->getPHID());
$objs = array();
foreach ($logs as $log) {
$obj = clone $template;
$obj->setChannel(idx($log, 'channel'));
$obj->setType(idx($log, 'type'));
$obj->setAuthor(idx($log, 'author'));
$obj->setEpoch(idx($log, 'epoch'));
$obj->setMessage(idx($log, 'message'));
$obj->save();
$objs[] = $obj;
}
return array_values(mpull($objs, 'getID'));
}
}
diff --git a/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php b/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php
index 5fcfab0b9c..aac289101d 100644
--- a/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php
+++ b/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php
@@ -1,90 +1,98 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
final class ConduitAPI_differential_find_Method extends ConduitAPIMethod {
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_DEPRECATED;
+ }
+
+ public function getMethodStatusDescription() {
+ return "Replaced by 'differential.query'.";
+ }
+
public function getMethodDescription() {
return "Query Differential revisions which match certain criteria.";
}
public function defineParamTypes() {
$types = array(
DifferentialRevisionListData::QUERY_OPEN_OWNED,
DifferentialRevisionListData::QUERY_COMMITTABLE,
DifferentialRevisionListData::QUERY_REVISION_IDS,
DifferentialRevisionListData::QUERY_PHIDS,
);
$types = implode(', ', $types);
return array(
'query' => 'required enum<'.$types.'>',
'guids' => 'required nonempty list<guids>',
);
}
public function defineReturnType() {
return 'nonempty list<dict>';
}
public function defineErrorTypes() {
return array(
);
}
protected function execute(ConduitAPIRequest $request) {
$query = $request->getValue('query');
$guids = $request->getValue('guids');
$results = array();
if (!$guids) {
return $results;
}
$revisions = id(new DifferentialRevisionListData(
$query,
(array)$guids))
->loadRevisions();
foreach ($revisions as $revision) {
$diff = $revision->loadActiveDiff();
if (!$diff) {
continue;
}
$id = $revision->getID();
$results[] = array(
'id' => $id,
'phid' => $revision->getPHID(),
'name' => $revision->getTitle(),
'uri' => PhabricatorEnv::getProductionURI('/D'.$id),
'dateCreated' => $revision->getDateCreated(),
'authorPHID' => $revision->getAuthorPHID(),
'statusName' =>
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus(
$revision->getStatus()),
'sourcePath' => $diff->getSourcePath(),
);
}
return $results;
}
}
diff --git a/src/applications/conduit/method/differential/getrevision/ConduitAPI_differential_getrevision_Method.php b/src/applications/conduit/method/differential/getrevision/ConduitAPI_differential_getrevision_Method.php
index 3a3f33f4a0..5e50142db5 100644
--- a/src/applications/conduit/method/differential/getrevision/ConduitAPI_differential_getrevision_Method.php
+++ b/src/applications/conduit/method/differential/getrevision/ConduitAPI_differential_getrevision_Method.php
@@ -1,121 +1,129 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
final class ConduitAPI_differential_getrevision_Method
extends ConduitAPIMethod {
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_DEPRECATED;
+ }
+
+ public function getMethodStatusDescription() {
+ return "Replaced by 'differential.query'.";
+ }
+
public function getMethodDescription() {
return "Load the content of a revision from Differential.";
}
public function defineParamTypes() {
return array(
'revision_id' => 'required id',
);
}
public function defineReturnType() {
return 'nonempty dict';
}
public function defineErrorTypes() {
return array(
'ERR_BAD_REVISION' => 'No such revision exists.',
);
}
protected function execute(ConduitAPIRequest $request) {
$diff = null;
$revision_id = $request->getValue('revision_id');
$revision = id(new DifferentialRevision())->load($revision_id);
if (!$revision) {
throw new ConduitException('ERR_BAD_REVISION');
}
$revision->loadRelationships();
$reviewer_phids = array_values($revision->getReviewers());
$diffs = $revision->loadDiffs();
$diff_dicts = array();
foreach ($diffs as $diff) {
$diff->attachChangesets($diff->loadChangesets());
// TODO: We could batch this to improve performance.
foreach ($diff->getChangesets() as $changeset) {
$changeset->attachHunks($changeset->loadHunks());
}
$diff_dicts[] = $diff->getDiffDict();
}
$commit_dicts = array();
$commit_phids = $revision->loadCommitPHIDs();
$handles = id(new PhabricatorObjectHandleData($commit_phids))
->loadHandles();
foreach ($commit_phids as $commit_phid) {
$commit_dicts[] = array(
'fullname' => $handles[$commit_phid]->getFullName(),
'dateCommitted' => $handles[$commit_phid]->getTimestamp(),
);
}
$auxiliary_fields = $this->loadAuxiliaryFields($revision);
$dict = array(
'id' => $revision->getID(),
'phid' => $revision->getPHID(),
'authorPHID' => $revision->getAuthorPHID(),
'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()),
'title' => $revision->getTitle(),
'status' => $revision->getStatus(),
'statusName' =>
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus(
$revision->getStatus()),
'summary' => $revision->getSummary(),
'testPlan' => $revision->getTestPlan(),
'lineCount' => $revision->getLineCount(),
'reviewerPHIDs' => $reviewer_phids,
'diffs' => $diff_dicts,
'commits' => $commit_dicts,
'auxiliary' => $auxiliary_fields,
);
return $dict;
}
private function loadAuxiliaryFields(DifferentialRevision $revision) {
$aux_fields = DifferentialFieldSelector::newSelector()
->getFieldSpecifications();
foreach ($aux_fields as $key => $aux_field) {
if (!$aux_field->shouldAppearOnConduitView()) {
unset($aux_fields[$key]);
}
}
$aux_fields = DifferentialAuxiliaryField::loadFromStorage(
$revision,
$aux_fields);
return mpull($aux_fields, 'getValueForConduit', 'getKeyForConduit');
}
}
diff --git a/src/applications/conduit/method/differential/getrevisionfeedback/ConduitAPI_differential_getrevisionfeedback_Method.php b/src/applications/conduit/method/differential/getrevisionfeedback/ConduitAPI_differential_getrevisionfeedback_Method.php
index 67c009c6f9..70954ae50c 100644
--- a/src/applications/conduit/method/differential/getrevisionfeedback/ConduitAPI_differential_getrevisionfeedback_Method.php
+++ b/src/applications/conduit/method/differential/getrevisionfeedback/ConduitAPI_differential_getrevisionfeedback_Method.php
@@ -1,75 +1,83 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
final class ConduitAPI_differential_getrevisionfeedback_Method
extends ConduitAPIMethod {
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_DEPRECATED;
+ }
+
+ public function getMethodStatusDescription() {
+ return "Replaced by 'differential.getrevisioncomments'.";
+ }
+
public function getMethodDescription() {
return "Retrieve Differential Revision Feedback.";
}
public function defineParamTypes() {
return array(
'ids' => 'required list<int>',
);
}
public function defineReturnType() {
return 'nonempty list<dict<string, wild>>';
}
public function defineErrorTypes() {
return array(
);
}
protected function execute(ConduitAPIRequest $request) {
$results = array();
$revision_ids = $request->getValue('ids');
if (!$revision_ids) {
return $results;
}
$comments = id(new DifferentialComment())->loadAllWhere(
'revisionID IN (%Ld)',
$revision_ids);
// Helper dictionary to keep track of where the id/action pair is
// stored in results array.
$indexes = array();
foreach ($comments as $comment) {
$action = $comment->getAction();
$revision_id = $comment->getRevisionID();
if (isset($indexes[$action.$revision_id])) {
$results[$indexes[$action.$revision_id]]['count']++;
} else {
$indexes[$action.$revision_id] = count($results);
$results[] = array('id' => $revision_id,
'action' => $action,
'count' => 1);
}
}
return $results;
}
}
diff --git a/src/applications/conduit/method/differential/updatetaskrevisionassoc/ConduitAPI_differential_updatetaskrevisionassoc_Method.php b/src/applications/conduit/method/differential/updatetaskrevisionassoc/ConduitAPI_differential_updatetaskrevisionassoc_Method.php
index 381faa7b70..9598159e99 100644
--- a/src/applications/conduit/method/differential/updatetaskrevisionassoc/ConduitAPI_differential_updatetaskrevisionassoc_Method.php
+++ b/src/applications/conduit/method/differential/updatetaskrevisionassoc/ConduitAPI_differential_updatetaskrevisionassoc_Method.php
@@ -1,73 +1,81 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
final class ConduitAPI_differential_updatetaskrevisionassoc_Method
extends ConduitAPIMethod {
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_DEPRECATED;
+ }
+
+ public function getMethodStatusDescription() {
+ return "This method should not really exist. Pretend it doesn't.";
+ }
+
public function getMethodDescription() {
return "Given a task together with its original and new associated ".
"revisions, update the revisions for their attached_tasks.";
}
public function defineParamTypes() {
return array(
'task_phid' => 'required nonempty string',
'orig_rev_phids' => 'required list<string>',
'new_rev_phids' => 'required list<string>',
);
}
public function defineReturnType() {
return 'void';
}
public function defineErrorTypes() {
return array(
'ERR_NO_TASKATTACHER_DEFINED' => 'No task attacher defined.',
);
}
protected function execute(ConduitAPIRequest $request) {
$task_phid = $request->getValue('task_phid');
$orig_rev_phids = $request->getValue('orig_rev_phids');
if (empty($orig_rev_phids)) {
$orig_rev_phids = array();
}
$new_rev_phids = $request->getValue('new_rev_phids');
if (empty($new_rev_phids)) {
$new_rev_phids = array();
}
try {
$task_attacher = PhabricatorEnv::newObjectFromConfig(
'differential.attach-task-class');
$task_attacher->updateTaskRevisionAssoc(
$task_phid,
$orig_rev_phids,
$new_rev_phids);
} catch (ReflectionException $ex) {
throw new ConduitException('ERR_NO_TASKATTACHER_DEFINED');
}
}
}
diff --git a/src/applications/conduit/method/feed/publish/ConduitAPI_feed_publish_Method.php b/src/applications/conduit/method/feed/publish/ConduitAPI_feed_publish_Method.php
index c2be4bf06f..05752a3994 100644
--- a/src/applications/conduit/method/feed/publish/ConduitAPI_feed_publish_Method.php
+++ b/src/applications/conduit/method/feed/publish/ConduitAPI_feed_publish_Method.php
@@ -1,66 +1,70 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
final class ConduitAPI_feed_publish_Method
extends ConduitAPIMethod {
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_UNSTABLE;
+ }
+
public function getMethodDescription() {
- return "(UNSTABLE!!!) Publish a story to the feed.";
+ return "Publish a story to the feed.";
}
public function defineParamTypes() {
return array(
'type' => 'required string',
'data' => 'required dict',
'time' => 'optional int',
);
}
public function defineErrorTypes() {
return array(
);
}
public function defineReturnType() {
return 'nonempty phid';
}
protected function execute(ConduitAPIRequest $request) {
$type = $request->getValue('type');
$data = $request->getValue('data');
$time = $request->getValue('time');
$author_phid = $request->getUser()->getPHID();
$phids = array($author_phid);
$publisher = new PhabricatorFeedStoryPublisher();
$publisher->setStoryType($type);
$publisher->setStoryData($data);
$publisher->setStoryTime($time);
$publisher->setRelatedPHIDs($phids);
$publisher->setStoryAuthorPHID($author_phid);
$data = $publisher->publish();
return $data->getPHID();
}
}
diff --git a/src/applications/conduit/method/feed/query/ConduitAPI_feed_query_Method.php b/src/applications/conduit/method/feed/query/ConduitAPI_feed_query_Method.php
index 82121d5de8..5181d52d42 100644
--- a/src/applications/conduit/method/feed/query/ConduitAPI_feed_query_Method.php
+++ b/src/applications/conduit/method/feed/query/ConduitAPI_feed_query_Method.php
@@ -1,135 +1,139 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
final class ConduitAPI_feed_query_Method extends ConduitAPIMethod {
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_UNSTABLE;
+ }
+
public function getMethodDescription() {
- return "(UNSTABLE!!) Query the feed for stories";
+ return "Query the feed for stories";
}
private function getDefaultLimit() {
return 100;
}
public function defineParamTypes() {
return array(
'filterPHIDs' => 'optional list <phid>',
'limit' => 'optional int (default '.$this->getDefaultLimit().')',
'after' => 'optional int',
'view' => 'optional string (data, html, html-summary)',
);
}
private function getSupportedViewTypes() {
return array(
'html' => 'Full HTML presentation of story',
'data' => 'Dictionary with various data of the story',
'html-summary' => 'Story contains only the title of the story',
);
}
public function defineErrorTypes() {
$view_types = array_keys($this->getSupportedViewTypes());
$view_types = implode(', ', $view_types);
return array(
'ERR-UNKNOWN-TYPE' =>
'Unsupported view type, possibles are: ' . $view_types
);
}
public function defineReturnType() {
return 'nonempty dict';
}
protected function execute(ConduitAPIRequest $request) {
$results = array();
$user = $request->getUser();
$view_type = $request->getValue('view');
if (!$view_type) {
$view_type = 'data';
}
$limit = $request->getValue('limit');
if (!$limit) {
$limit = $this->getDefaultLimit();
}
$filter_phids = $request->getValue('filter_phids');
if (!$filter_phids) {
$filter_phids = array();
}
$after = $request->getValue('after');
$query = id(new PhabricatorFeedQuery())
->setLimit($limit)
->setFilterPHIDs($filter_phids)
->setAfter($after);
$stories = $query->execute();
if ($stories) {
$handle_phids = array_mergev(mpull($stories, 'getRequiredHandlePHIDs'));
$handles = id(new PhabricatorObjectHandleData($handle_phids))
->loadHandles();
foreach ($stories as $story) {
$story->setHandles($handles);
$story_data = $story->getStoryData();
$data = null;
$view = $story->renderView();
$view->setEpoch($story->getEpoch());
$view->setViewer($user);
switch ($view_type) {
case 'html':
$data = $view->render();
break;
case 'html-summary':
$view->setOneLineStory(true);
$data = $view->render();
break;
case 'data':
$data = array(
'class' => $story_data->getStoryType(),
'epoch' => $story_data->getEpoch(),
'authorPHID' => $story_data->getAuthorPHID(),
'chronologicalKey' => $story_data->getChronologicalKey(),
'data' => $story_data->getStoryData(),
);
break;
default:
throw new ConduitException('ERR-UNKNOWN-TYPE');
}
$results[$story_data->getPHID()] = $data;
}
}
return $results;
}
}
diff --git a/src/applications/conduit/method/phid/info/ConduitAPI_phid_info_Method.php b/src/applications/conduit/method/phid/info/ConduitAPI_phid_info_Method.php
index 4c57d8f799..e908df409d 100644
--- a/src/applications/conduit/method/phid/info/ConduitAPI_phid_info_Method.php
+++ b/src/applications/conduit/method/phid/info/ConduitAPI_phid_info_Method.php
@@ -1,60 +1,68 @@
<?php
/*
- * Copyright 2011 Facebook, Inc.
+ * Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
final class ConduitAPI_phid_info_Method
extends ConduitAPI_phid_Method {
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_DEPRECATED;
+ }
+
+ public function getMethodStatusDescription() {
+ return "Replaced by 'phid.query'.";
+ }
+
public function getMethodDescription() {
return "Retrieve information about an arbitrary PHID.";
}
public function defineParamTypes() {
return array(
'phid' => 'required phid',
);
}
public function defineReturnType() {
return 'nonempty dict<string, wild>';
}
public function defineErrorTypes() {
return array(
'ERR-BAD-PHID' => 'No such object exists.',
);
}
protected function execute(ConduitAPIRequest $request) {
$phid = $request->getValue('phid');
$handles = id(new PhabricatorObjectHandleData(array($phid)))
->loadHandles();
$handle = $handles[$phid];
if (!$handle->isComplete()) {
throw new ConduitException('ERR-BAD-PHID');
}
return $this->buildHandleInformationDictionary($handle);
}
}
diff --git a/src/applications/conduit/method/remarkup/process/ConduitAPI_remarkup_process_Method.php b/src/applications/conduit/method/remarkup/process/ConduitAPI_remarkup_process_Method.php
index fffb153fa4..6d8d975a79 100644
--- a/src/applications/conduit/method/remarkup/process/ConduitAPI_remarkup_process_Method.php
+++ b/src/applications/conduit/method/remarkup/process/ConduitAPI_remarkup_process_Method.php
@@ -1,71 +1,75 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class ConduitAPI_remarkup_process_Method extends ConduitAPIMethod {
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_UNSTABLE;
+ }
+
public function getMethodDescription() {
return 'Process text through remarkup in phabricator context.';
}
public function defineReturnType() {
return 'nonempty dict';
}
public function defineErrorTypes() {
return array(
'ERR-NO-CONTENT' => 'Content may not be empty.',
'ERR-INVALID-ENGINE' => 'Invalid markup engine.',
);
}
public function defineParamTypes() {
$available_contexts = array_keys($this->getEngineContexts());
$available_contexts = implode(', ', $available_contexts);
return array(
'context' => 'required enum<'.$available_contexts.'>',
'content' => 'required string',
);
}
protected function execute(ConduitAPIRequest $request) {
$content = $request->getValue('content');
$context = $request->getValue('context');
$engine_class = idx($this->getEngineContexts(), $context);
if (!$engine_class) {
throw new ConduitException('ERR-INVALID_ENGINE');
}
$engine = PhabricatorMarkupEngine::$engine_class();
$result = array(
'content' => $engine->markupText($content),
);
return $result;
}
private function getEngineContexts() {
return array(
'phriction' => 'newPhrictionMarkupEngine',
'maniphest' => 'newManiphestMarkupEngine',
'differential' => 'newDifferentialMarkupEngine',
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 15:56 (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126226
Default Alt Text
(44 KB)

Event Timeline