Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2895206
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/conduit/method/differential/getdiff/ConduitAPI_differential_getdiff_Method.php b/src/applications/conduit/method/differential/getdiff/ConduitAPI_differential_getdiff_Method.php
index 2968079017..df9a28d00b 100644
--- a/src/applications/conduit/method/differential/getdiff/ConduitAPI_differential_getdiff_Method.php
+++ b/src/applications/conduit/method/differential/getdiff/ConduitAPI_differential_getdiff_Method.php
@@ -1,78 +1,82 @@
<?php
/*
* Copyright 2011 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
*/
class ConduitAPI_differential_getdiff_Method extends ConduitAPIMethod {
public function getMethodDescription() {
return "Load the content of a diff from Differential.";
}
public function defineParamTypes() {
return array(
'revision_id' => 'optional id',
'diff_id' => 'optional id',
);
}
public function defineReturnType() {
return 'nonempty dict';
}
public function defineErrorTypes() {
return array(
'ERR_BAD_REVISION' => 'No such revision exists.',
'ERR_BAD_DIFF' => 'No such diff exists.',
);
}
+ public function shouldRequireAuthentication() {
+ return !PhabricatorEnv::getEnvConfig('differential.anonymous-access');
+ }
+
protected function execute(ConduitAPIRequest $request) {
$diff = null;
$revision_id = $request->getValue('revision_id');
if ($revision_id) {
$revision = id(new DifferentialRevision())->load($revision_id);
if (!$revision) {
throw new ConduitException('ERR_BAD_REVISION');
}
$diff = id(new DifferentialDiff())->loadOneWhere(
'revisionID = %d ORDER BY id DESC LIMIT 1',
$revision->getID());
} else {
$diff_id = $request->getValue('diff_id');
if ($diff_id) {
$diff = id(new DifferentialDiff())->load($diff_id);
}
}
if (!$diff) {
throw new ConduitException('ERR_BAD_DIFF');
}
$diff->attachChangesets($diff->loadChangesets());
// TODO: We could batch this to improve performance.
foreach ($diff->getChangesets() as $changeset) {
$changeset->attachHunks($changeset->loadHunks());
}
return $diff->getDiffDict();
}
}
diff --git a/src/applications/conduit/method/differential/getdiff/__init__.php b/src/applications/conduit/method/differential/getdiff/__init__.php
index 15399190d3..ee5f6cc825 100644
--- a/src/applications/conduit/method/differential/getdiff/__init__.php
+++ b/src/applications/conduit/method/differential/getdiff/__init__.php
@@ -1,17 +1,18 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/conduit/method/base');
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
phutil_require_module('phabricator', 'applications/differential/storage/diff');
phutil_require_module('phabricator', 'applications/differential/storage/revision');
+phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phutil', 'utils');
phutil_require_source('ConduitAPI_differential_getdiff_Method.php');
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Jan 19 2025, 21:06 (6 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1128751
Default Alt Text
(3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment