Page MenuHomePhabricator

D17123.diff
No OneTemporary

D17123.diff

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
@@ -5058,6 +5058,7 @@
'DifferentialDiff' => array(
'DifferentialDAO',
'PhabricatorPolicyInterface',
+ 'PhabricatorExtendedPolicyInterface',
'HarbormasterBuildableInterface',
'HarbormasterCircleCIBuildableInterface',
'PhabricatorApplicationTransactionInterface',
diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php
--- a/src/applications/differential/controller/DifferentialRevisionViewController.php
+++ b/src/applications/differential/controller/DifferentialRevisionViewController.php
@@ -16,18 +16,17 @@
$revision = id(new DifferentialRevisionQuery())
->withIDs(array($this->revisionID))
- ->setViewer($request->getUser())
+ ->setViewer($viewer)
->needRelationships(true)
->needReviewerStatus(true)
->needReviewerAuthority(true)
->executeOne();
-
if (!$revision) {
return new Aphront404Response();
}
$diffs = id(new DifferentialDiffQuery())
- ->setViewer($request->getUser())
+ ->setViewer($viewer)
->withRevisionIDs(array($this->revisionID))
->execute();
$diffs = array_reverse($diffs, $preserve_keys = true);
diff --git a/src/applications/differential/storage/DifferentialDiff.php b/src/applications/differential/storage/DifferentialDiff.php
--- a/src/applications/differential/storage/DifferentialDiff.php
+++ b/src/applications/differential/storage/DifferentialDiff.php
@@ -4,6 +4,7 @@
extends DifferentialDAO
implements
PhabricatorPolicyInterface,
+ PhabricatorExtendedPolicyInterface,
HarbormasterBuildableInterface,
HarbormasterCircleCIBuildableInterface,
PhabricatorApplicationTransactionInterface,
@@ -429,7 +430,7 @@
public function getPolicy($capability) {
if ($this->hasRevision()) {
- return $this->getRevision()->getPolicy($capability);
+ return PhabricatorPolicies::getMostOpenPolicy();
}
return $this->viewPolicy;
@@ -440,7 +441,7 @@
return $this->getRevision()->hasAutomaticCapability($capability, $viewer);
}
- return ($this->getAuthorPHID() == $viewer->getPhid());
+ return ($this->getAuthorPHID() == $viewer->getPHID());
}
public function describeAutomaticCapability($capability) {
@@ -448,10 +449,31 @@
return pht(
'This diff is attached to a revision, and inherits its policies.');
}
+
return pht('The author of a diff can see it.');
}
+/* -( PhabricatorExtendedPolicyInterface )--------------------------------- */
+
+
+ public function getExtendedPolicy($capability, PhabricatorUser $viewer) {
+ $extended = array();
+
+ switch ($capability) {
+ case PhabricatorPolicyCapability::CAN_VIEW:
+ if ($this->hasRevision()) {
+ $extended[] = array(
+ $this->getRevision(),
+ PhabricatorPolicyCapability::CAN_VIEW,
+ );
+ }
+ break;
+ }
+
+ return $extended;
+ }
+
/* -( HarbormasterBuildableInterface )------------------------------------- */

File Metadata

Mime Type
text/plain
Expires
Oct 18 2024, 2:49 AM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6720542
Default Alt Text
D17123.diff (3 KB)

Event Timeline