mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 04:50:55 +01:00
Make PhabricatorPolicyInterface require a getPHID() method
Summary: Ref T603. This cleans up an existing callsite in the policy filter, and opens up some stuff in the future. Some policy objects don't have real PHIDs: PhabricatorTokenGiven PhabricatorSavedQuery PhabricatorNamedQuery PhrequentUserTime PhabricatorFlag PhabricatorDaemonLog PhabricatorConduitMethodCallLog ConduitAPIMethod PhabricatorChatLogEvent PhabricatorChatLogChannel Although it would be reasonable to add real PHIDs to some of these (like `ChatLogChannel`), it probably doesn't make much sense for others (`DaemonLog`, `MethodCallLog`). Just let them return `null`. Also remove some duplicate `$id` and `$phid` properties. These are declared on `PhabricatorLiskDAO` and do not need to be redeclared. Test Plan: Ran the `testEverythingImplemented` unit test, which verifies that all classes conform to the interface. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D7306
This commit is contained in:
parent
0ce4f6d176
commit
073cb0e78c
31 changed files with 24 additions and 46 deletions
|
@ -25,7 +25,7 @@ abstract class ConduitAPIMethod
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is mostly for compatibility with
|
* This is mostly for compatibility with
|
||||||
* @{class:AphrontCursorPagedPolicyAwareQuery}.
|
* @{class:PhabricatorCursorPagedPolicyAwareQuery}.
|
||||||
*/
|
*/
|
||||||
public function getID() {
|
public function getID() {
|
||||||
return $this->getAPIMethodName();
|
return $this->getAPIMethodName();
|
||||||
|
@ -166,6 +166,10 @@ abstract class ConduitAPIMethod
|
||||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function getPHID() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCapabilities() {
|
public function getCapabilities() {
|
||||||
return array(
|
return array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
final class PhabricatorConfigEntry extends PhabricatorConfigEntryDAO
|
final class PhabricatorConfigEntry extends PhabricatorConfigEntryDAO
|
||||||
implements PhabricatorPolicyInterface {
|
implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $id;
|
|
||||||
protected $phid;
|
|
||||||
protected $namespace;
|
protected $namespace;
|
||||||
protected $configKey;
|
protected $configKey;
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
final class ConpherenceThread extends ConpherenceDAO
|
final class ConpherenceThread extends ConpherenceDAO
|
||||||
implements PhabricatorPolicyInterface {
|
implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $id;
|
|
||||||
protected $phid;
|
|
||||||
protected $title;
|
protected $title;
|
||||||
protected $messageCount;
|
protected $messageCount;
|
||||||
protected $recentParticipantPHIDs = array();
|
protected $recentParticipantPHIDs = array();
|
||||||
|
|
|
@ -7,8 +7,6 @@ final class PhabricatorCountdown
|
||||||
extends PhabricatorCountdownDAO
|
extends PhabricatorCountdownDAO
|
||||||
implements PhabricatorPolicyInterface {
|
implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $id;
|
|
||||||
protected $phid;
|
|
||||||
protected $title;
|
protected $title;
|
||||||
protected $authorPHID;
|
protected $authorPHID;
|
||||||
protected $epoch;
|
protected $epoch;
|
||||||
|
|
|
@ -26,6 +26,9 @@ final class PhabricatorDaemonLog extends PhabricatorDaemonDAO
|
||||||
|
|
||||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
public function getPHID() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCapabilities() {
|
public function getCapabilities() {
|
||||||
return array(
|
return array(
|
||||||
|
|
|
@ -13,7 +13,6 @@ final class DifferentialRevision extends DifferentialDAO
|
||||||
protected $summary = '';
|
protected $summary = '';
|
||||||
protected $testPlan = '';
|
protected $testPlan = '';
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $authorPHID;
|
protected $authorPHID;
|
||||||
protected $lastReviewerPHID;
|
protected $lastReviewerPHID;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
final class DivinerLiveBook extends DivinerDAO
|
final class DivinerLiveBook extends DivinerDAO
|
||||||
implements PhabricatorPolicyInterface {
|
implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $viewPolicy;
|
protected $viewPolicy;
|
||||||
protected $configurationData = array();
|
protected $configurationData = array();
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
final class DivinerLiveSymbol extends DivinerDAO
|
final class DivinerLiveSymbol extends DivinerDAO
|
||||||
implements PhabricatorPolicyInterface, PhabricatorMarkupInterface {
|
implements PhabricatorPolicyInterface, PhabricatorMarkupInterface {
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $bookPHID;
|
protected $bookPHID;
|
||||||
protected $context;
|
protected $context;
|
||||||
protected $type;
|
protected $type;
|
||||||
|
|
|
@ -283,6 +283,9 @@ abstract class PhabricatorFeedStory implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
|
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
|
||||||
|
|
||||||
|
public function getPHID() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @task policy
|
* @task policy
|
||||||
|
|
|
@ -14,7 +14,6 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
||||||
const METADATA_IMAGE_WIDTH = 'width';
|
const METADATA_IMAGE_WIDTH = 'width';
|
||||||
const METADATA_IMAGE_HEIGHT = 'height';
|
const METADATA_IMAGE_HEIGHT = 'height';
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $mimeType;
|
protected $mimeType;
|
||||||
protected $byteSize;
|
protected $byteSize;
|
||||||
|
|
|
@ -3,9 +3,6 @@
|
||||||
final class HeraldTranscript extends HeraldDAO
|
final class HeraldTranscript extends HeraldDAO
|
||||||
implements PhabricatorPolicyInterface {
|
implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $id;
|
|
||||||
protected $phid;
|
|
||||||
|
|
||||||
protected $objectTranscript;
|
protected $objectTranscript;
|
||||||
protected $ruleTranscripts = array();
|
protected $ruleTranscripts = array();
|
||||||
protected $conditionTranscripts = array();
|
protected $conditionTranscripts = array();
|
||||||
|
|
|
@ -9,7 +9,6 @@ final class LegalpadDocument extends LegalpadDAO
|
||||||
PhabricatorSubscribableInterface,
|
PhabricatorSubscribableInterface,
|
||||||
PhabricatorApplicationTransactionInterface {
|
PhabricatorApplicationTransactionInterface {
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $title;
|
protected $title;
|
||||||
protected $contributorCount;
|
protected $contributorCount;
|
||||||
protected $recentContributorPHIDs = array();
|
protected $recentContributorPHIDs = array();
|
||||||
|
|
|
@ -8,7 +8,6 @@ final class PhabricatorFileImageMacro extends PhabricatorFileDAO
|
||||||
|
|
||||||
protected $authorPHID;
|
protected $authorPHID;
|
||||||
protected $filePHID;
|
protected $filePHID;
|
||||||
protected $phid;
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $isDisabled = 0;
|
protected $isDisabled = 0;
|
||||||
protected $audioPHID;
|
protected $audioPHID;
|
||||||
|
|
|
@ -4,7 +4,6 @@ final class PhabricatorMetaMTAMailingList extends PhabricatorMetaMTADAO
|
||||||
implements PhabricatorPolicyInterface {
|
implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $phid;
|
|
||||||
protected $email;
|
protected $email;
|
||||||
protected $uri;
|
protected $uri;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ final class ManiphestTask extends ManiphestDAO
|
||||||
|
|
||||||
const MARKUP_FIELD_DESCRIPTION = 'markup:desc';
|
const MARKUP_FIELD_DESCRIPTION = 'markup:desc';
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $authorPHID;
|
protected $authorPHID;
|
||||||
protected $ownerPHID;
|
protected $ownerPHID;
|
||||||
protected $ccPHIDs = array();
|
protected $ccPHIDs = array();
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
final class PhabricatorOwnersPackage extends PhabricatorOwnersDAO
|
final class PhabricatorOwnersPackage extends PhabricatorOwnersDAO
|
||||||
implements PhabricatorPolicyInterface {
|
implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $originalName;
|
protected $originalName;
|
||||||
protected $auditingEnabled;
|
protected $auditingEnabled;
|
||||||
|
|
|
@ -9,7 +9,6 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
|
||||||
PhabricatorTokenReceiverInterface,
|
PhabricatorTokenReceiverInterface,
|
||||||
PhabricatorPolicyInterface {
|
PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $title;
|
protected $title;
|
||||||
protected $authorPHID;
|
protected $authorPHID;
|
||||||
protected $filePHID;
|
protected $filePHID;
|
||||||
|
|
|
@ -11,7 +11,6 @@ final class PhabricatorUser
|
||||||
const NAMETOKEN_TABLE = 'user_nametoken';
|
const NAMETOKEN_TABLE = 'user_nametoken';
|
||||||
const MAXIMUM_USERNAME_LENGTH = 64;
|
const MAXIMUM_USERNAME_LENGTH = 64;
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $userName;
|
protected $userName;
|
||||||
protected $realName;
|
protected $realName;
|
||||||
protected $sex;
|
protected $sex;
|
||||||
|
|
|
@ -10,8 +10,6 @@ final class PhameBlog extends PhameDAO
|
||||||
|
|
||||||
const SKIN_DEFAULT = 'oblivious';
|
const SKIN_DEFAULT = 'oblivious';
|
||||||
|
|
||||||
protected $id;
|
|
||||||
protected $phid;
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $description;
|
protected $description;
|
||||||
protected $domain;
|
protected $domain;
|
||||||
|
|
|
@ -15,8 +15,6 @@ final class PhamePost extends PhameDAO
|
||||||
const VISIBILITY_DRAFT = 0;
|
const VISIBILITY_DRAFT = 0;
|
||||||
const VISIBILITY_PUBLISHED = 1;
|
const VISIBILITY_PUBLISHED = 1;
|
||||||
|
|
||||||
protected $id;
|
|
||||||
protected $phid;
|
|
||||||
protected $bloggerPHID;
|
protected $bloggerPHID;
|
||||||
protected $title;
|
protected $title;
|
||||||
protected $phameTitle;
|
protected $phameTitle;
|
||||||
|
|
|
@ -9,8 +9,6 @@ final class PhrictionDocument extends PhrictionDAO
|
||||||
PhabricatorSubscribableInterface,
|
PhabricatorSubscribableInterface,
|
||||||
PhabricatorTokenReceiverInterface {
|
PhabricatorTokenReceiverInterface {
|
||||||
|
|
||||||
protected $id;
|
|
||||||
protected $phid;
|
|
||||||
protected $slug;
|
protected $slug;
|
||||||
protected $depth;
|
protected $depth;
|
||||||
protected $contentID;
|
protected $contentID;
|
||||||
|
|
|
@ -10,6 +10,10 @@ final class PhabricatorPolicyTestObject
|
||||||
private $policies = array();
|
private $policies = array();
|
||||||
private $automaticCapabilities = array();
|
private $automaticCapabilities = array();
|
||||||
|
|
||||||
|
public function getPHID() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCapabilities() {
|
public function getCapabilities() {
|
||||||
return $this->capabilities;
|
return $this->capabilities;
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,19 +282,9 @@ final class PhabricatorPolicyFilter {
|
||||||
|
|
||||||
$details = array_filter(array_merge(array($more), (array)$exceptions));
|
$details = array_filter(array_merge(array($more), (array)$exceptions));
|
||||||
|
|
||||||
// NOTE: Not every policy object has a PHID, just pull an arbitrary
|
// NOTE: Not every type of policy object has a real PHID; just load an
|
||||||
// "unknown object" handle if this fails. We're just using this to provide
|
// empty handle if a real PHID isn't available.
|
||||||
// a better error message if we can.
|
$phid = nonempty($object->getPHID(), PhabricatorPHIDConstants::PHID_VOID);
|
||||||
|
|
||||||
$phid = '?';
|
|
||||||
if (($object instanceof PhabricatorLiskDAO) ||
|
|
||||||
(method_exists($object, 'getPHID'))) {
|
|
||||||
try {
|
|
||||||
$phid = $object->getPHID();
|
|
||||||
} catch (Exception $ignored) {
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$handle = id(new PhabricatorHandleQuery())
|
$handle = id(new PhabricatorHandleQuery())
|
||||||
->setViewer($this->viewer)
|
->setViewer($this->viewer)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
interface PhabricatorPolicyInterface {
|
interface PhabricatorPolicyInterface {
|
||||||
|
|
||||||
|
public function getPHID();
|
||||||
public function getCapabilities();
|
public function getCapabilities();
|
||||||
public function getPolicy($capability);
|
public function getPolicy($capability);
|
||||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer);
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer);
|
||||||
|
|
|
@ -4,7 +4,6 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
||||||
implements PhabricatorPolicyInterface {
|
implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $phid;
|
|
||||||
protected $status = PhabricatorProjectStatus::STATUS_ACTIVE;
|
protected $status = PhabricatorProjectStatus::STATUS_ACTIVE;
|
||||||
protected $authorPHID;
|
protected $authorPHID;
|
||||||
protected $subprojectPHIDs = array();
|
protected $subprojectPHIDs = array();
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
final class ReleephBranch extends ReleephDAO
|
final class ReleephBranch extends ReleephDAO
|
||||||
implements PhabricatorPolicyInterface {
|
implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $releephProjectID;
|
protected $releephProjectID;
|
||||||
protected $isActive;
|
protected $isActive;
|
||||||
protected $createdByUserPHID;
|
protected $createdByUserPHID;
|
||||||
|
|
|
@ -10,7 +10,6 @@ final class ReleephProject extends ReleephDAO
|
||||||
const COMMIT_AUTHOR_FROM_DIFF = 'commit-author-is-from-diff';
|
const COMMIT_AUTHOR_FROM_DIFF = 'commit-author-is-from-diff';
|
||||||
const COMMIT_AUTHOR_REQUESTOR = 'commit-author-is-requestor';
|
const COMMIT_AUTHOR_REQUESTOR = 'commit-author-is-requestor';
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $name;
|
protected $name;
|
||||||
|
|
||||||
// Specifying the place to pick from is a requirement for svn, though not
|
// Specifying the place to pick from is a requirement for svn, though not
|
||||||
|
|
|
@ -5,7 +5,6 @@ final class ReleephRequest extends ReleephDAO
|
||||||
PhabricatorPolicyInterface,
|
PhabricatorPolicyInterface,
|
||||||
PhabricatorCustomFieldInterface {
|
PhabricatorCustomFieldInterface {
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $branchID;
|
protected $branchID;
|
||||||
protected $requestUserPHID;
|
protected $requestUserPHID;
|
||||||
protected $details = array();
|
protected $details = array();
|
||||||
|
|
|
@ -25,7 +25,6 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
const TABLE_BADCOMMIT = 'repository_badcommit';
|
const TABLE_BADCOMMIT = 'repository_badcommit';
|
||||||
const TABLE_LINTMESSAGE = 'repository_lintmessage';
|
const TABLE_LINTMESSAGE = 'repository_lintmessage';
|
||||||
|
|
||||||
protected $phid;
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $callsign;
|
protected $callsign;
|
||||||
protected $uuid;
|
protected $uuid;
|
||||||
|
|
|
@ -8,7 +8,6 @@ final class PhabricatorRepositoryArcanistProject
|
||||||
implements PhabricatorPolicyInterface {
|
implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $phid;
|
|
||||||
protected $repositoryID;
|
protected $repositoryID;
|
||||||
|
|
||||||
protected $symbolIndexLanguages = array();
|
protected $symbolIndexLanguages = array();
|
||||||
|
|
|
@ -892,6 +892,11 @@ abstract class LiskDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getPHID() {
|
||||||
|
return $this->phid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if a property exists.
|
* Test if a property exists.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue