@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+24 -46
+5 -1
src/applications/conduit/method/ConduitAPIMethod.php
··· 25 25 26 26 /** 27 27 * This is mostly for compatibility with 28 - * @{class:AphrontCursorPagedPolicyAwareQuery}. 28 + * @{class:PhabricatorCursorPagedPolicyAwareQuery}. 29 29 */ 30 30 public function getID() { 31 31 return $this->getAPIMethodName(); ··· 165 165 166 166 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 167 167 168 + 169 + public function getPHID() { 170 + return null; 171 + } 168 172 169 173 public function getCapabilities() { 170 174 return array(
-2
src/applications/config/storage/PhabricatorConfigEntry.php
··· 3 3 final class PhabricatorConfigEntry extends PhabricatorConfigEntryDAO 4 4 implements PhabricatorPolicyInterface { 5 5 6 - protected $id; 7 - protected $phid; 8 6 protected $namespace; 9 7 protected $configKey; 10 8 protected $value;
-2
src/applications/conpherence/storage/ConpherenceThread.php
··· 6 6 final class ConpherenceThread extends ConpherenceDAO 7 7 implements PhabricatorPolicyInterface { 8 8 9 - protected $id; 10 - protected $phid; 11 9 protected $title; 12 10 protected $messageCount; 13 11 protected $recentParticipantPHIDs = array();
-2
src/applications/countdown/storage/PhabricatorCountdown.php
··· 7 7 extends PhabricatorCountdownDAO 8 8 implements PhabricatorPolicyInterface { 9 9 10 - protected $id; 11 - protected $phid; 12 10 protected $title; 13 11 protected $authorPHID; 14 12 protected $epoch;
+3
src/applications/daemon/storage/PhabricatorDaemonLog.php
··· 26 26 27 27 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 28 28 29 + public function getPHID() { 30 + return null; 31 + } 29 32 30 33 public function getCapabilities() { 31 34 return array(
-1
src/applications/differential/storage/DifferentialRevision.php
··· 13 13 protected $summary = ''; 14 14 protected $testPlan = ''; 15 15 16 - protected $phid; 17 16 protected $authorPHID; 18 17 protected $lastReviewerPHID; 19 18
-1
src/applications/diviner/storage/DivinerLiveBook.php
··· 3 3 final class DivinerLiveBook extends DivinerDAO 4 4 implements PhabricatorPolicyInterface { 5 5 6 - protected $phid; 7 6 protected $name; 8 7 protected $viewPolicy; 9 8 protected $configurationData = array();
-1
src/applications/diviner/storage/DivinerLiveSymbol.php
··· 3 3 final class DivinerLiveSymbol extends DivinerDAO 4 4 implements PhabricatorPolicyInterface, PhabricatorMarkupInterface { 5 5 6 - protected $phid; 7 6 protected $bookPHID; 8 7 protected $context; 9 8 protected $type;
+3
src/applications/feed/story/PhabricatorFeedStory.php
··· 283 283 284 284 /* -( PhabricatorPolicyInterface Implementation )-------------------------- */ 285 285 286 + public function getPHID() { 287 + return null; 288 + } 286 289 287 290 /** 288 291 * @task policy
-1
src/applications/files/storage/PhabricatorFile.php
··· 14 14 const METADATA_IMAGE_WIDTH = 'width'; 15 15 const METADATA_IMAGE_HEIGHT = 'height'; 16 16 17 - protected $phid; 18 17 protected $name; 19 18 protected $mimeType; 20 19 protected $byteSize;
-3
src/applications/herald/storage/transcript/HeraldTranscript.php
··· 3 3 final class HeraldTranscript extends HeraldDAO 4 4 implements PhabricatorPolicyInterface { 5 5 6 - protected $id; 7 - protected $phid; 8 - 9 6 protected $objectTranscript; 10 7 protected $ruleTranscripts = array(); 11 8 protected $conditionTranscripts = array();
-1
src/applications/legalpad/storage/LegalpadDocument.php
··· 9 9 PhabricatorSubscribableInterface, 10 10 PhabricatorApplicationTransactionInterface { 11 11 12 - protected $phid; 13 12 protected $title; 14 13 protected $contributorCount; 15 14 protected $recentContributorPHIDs = array();
-1
src/applications/macro/storage/PhabricatorFileImageMacro.php
··· 8 8 9 9 protected $authorPHID; 10 10 protected $filePHID; 11 - protected $phid; 12 11 protected $name; 13 12 protected $isDisabled = 0; 14 13 protected $audioPHID;
-1
src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php
··· 4 4 implements PhabricatorPolicyInterface { 5 5 6 6 protected $name; 7 - protected $phid; 8 7 protected $email; 9 8 protected $uri; 10 9
-1
src/applications/maniphest/storage/ManiphestTask.php
··· 10 10 11 11 const MARKUP_FIELD_DESCRIPTION = 'markup:desc'; 12 12 13 - protected $phid; 14 13 protected $authorPHID; 15 14 protected $ownerPHID; 16 15 protected $ccPHIDs = array();
-1
src/applications/owners/storage/PhabricatorOwnersPackage.php
··· 3 3 final class PhabricatorOwnersPackage extends PhabricatorOwnersDAO 4 4 implements PhabricatorPolicyInterface { 5 5 6 - protected $phid; 7 6 protected $name; 8 7 protected $originalName; 9 8 protected $auditingEnabled;
-1
src/applications/paste/storage/PhabricatorPaste.php
··· 9 9 PhabricatorTokenReceiverInterface, 10 10 PhabricatorPolicyInterface { 11 11 12 - protected $phid; 13 12 protected $title; 14 13 protected $authorPHID; 15 14 protected $filePHID;
-1
src/applications/people/storage/PhabricatorUser.php
··· 11 11 const NAMETOKEN_TABLE = 'user_nametoken'; 12 12 const MAXIMUM_USERNAME_LENGTH = 64; 13 13 14 - protected $phid; 15 14 protected $userName; 16 15 protected $realName; 17 16 protected $sex;
-2
src/applications/phame/storage/PhameBlog.php
··· 10 10 11 11 const SKIN_DEFAULT = 'oblivious'; 12 12 13 - protected $id; 14 - protected $phid; 15 13 protected $name; 16 14 protected $description; 17 15 protected $domain;
-2
src/applications/phame/storage/PhamePost.php
··· 15 15 const VISIBILITY_DRAFT = 0; 16 16 const VISIBILITY_PUBLISHED = 1; 17 17 18 - protected $id; 19 - protected $phid; 20 18 protected $bloggerPHID; 21 19 protected $title; 22 20 protected $phameTitle;
-2
src/applications/phriction/storage/PhrictionDocument.php
··· 9 9 PhabricatorSubscribableInterface, 10 10 PhabricatorTokenReceiverInterface { 11 11 12 - protected $id; 13 - protected $phid; 14 12 protected $slug; 15 13 protected $depth; 16 14 protected $contentID;
+4
src/applications/policy/__tests__/PhabricatorPolicyTestObject.php
··· 10 10 private $policies = array(); 11 11 private $automaticCapabilities = array(); 12 12 13 + public function getPHID() { 14 + return null; 15 + } 16 + 13 17 public function getCapabilities() { 14 18 return $this->capabilities; 15 19 }
+3 -13
src/applications/policy/filter/PhabricatorPolicyFilter.php
··· 282 282 283 283 $details = array_filter(array_merge(array($more), (array)$exceptions)); 284 284 285 - // NOTE: Not every policy object has a PHID, just pull an arbitrary 286 - // "unknown object" handle if this fails. We're just using this to provide 287 - // a better error message if we can. 288 - 289 - $phid = '?'; 290 - if (($object instanceof PhabricatorLiskDAO) || 291 - (method_exists($object, 'getPHID'))) { 292 - try { 293 - $phid = $object->getPHID(); 294 - } catch (Exception $ignored) { 295 - // Ignore. 296 - } 297 - } 285 + // NOTE: Not every type of policy object has a real PHID; just load an 286 + // empty handle if a real PHID isn't available. 287 + $phid = nonempty($object->getPHID(), PhabricatorPHIDConstants::PHID_VOID); 298 288 299 289 $handle = id(new PhabricatorHandleQuery()) 300 290 ->setViewer($this->viewer)
+1
src/applications/policy/interface/PhabricatorPolicyInterface.php
··· 2 2 3 3 interface PhabricatorPolicyInterface { 4 4 5 + public function getPHID(); 5 6 public function getCapabilities(); 6 7 public function getPolicy($capability); 7 8 public function hasAutomaticCapability($capability, PhabricatorUser $viewer);
-1
src/applications/project/storage/PhabricatorProject.php
··· 4 4 implements PhabricatorPolicyInterface { 5 5 6 6 protected $name; 7 - protected $phid; 8 7 protected $status = PhabricatorProjectStatus::STATUS_ACTIVE; 9 8 protected $authorPHID; 10 9 protected $subprojectPHIDs = array();
-1
src/applications/releeph/storage/ReleephBranch.php
··· 3 3 final class ReleephBranch extends ReleephDAO 4 4 implements PhabricatorPolicyInterface { 5 5 6 - protected $phid; 7 6 protected $releephProjectID; 8 7 protected $isActive; 9 8 protected $createdByUserPHID;
-1
src/applications/releeph/storage/ReleephProject.php
··· 10 10 const COMMIT_AUTHOR_FROM_DIFF = 'commit-author-is-from-diff'; 11 11 const COMMIT_AUTHOR_REQUESTOR = 'commit-author-is-requestor'; 12 12 13 - protected $phid; 14 13 protected $name; 15 14 16 15 // Specifying the place to pick from is a requirement for svn, though not
-1
src/applications/releeph/storage/ReleephRequest.php
··· 5 5 PhabricatorPolicyInterface, 6 6 PhabricatorCustomFieldInterface { 7 7 8 - protected $phid; 9 8 protected $branchID; 10 9 protected $requestUserPHID; 11 10 protected $details = array();
-1
src/applications/repository/storage/PhabricatorRepository.php
··· 25 25 const TABLE_BADCOMMIT = 'repository_badcommit'; 26 26 const TABLE_LINTMESSAGE = 'repository_lintmessage'; 27 27 28 - protected $phid; 29 28 protected $name; 30 29 protected $callsign; 31 30 protected $uuid;
-1
src/applications/repository/storage/PhabricatorRepositoryArcanistProject.php
··· 8 8 implements PhabricatorPolicyInterface { 9 9 10 10 protected $name; 11 - protected $phid; 12 11 protected $repositoryID; 13 12 14 13 protected $symbolIndexLanguages = array();
+5
src/infrastructure/storage/lisk/LiskDAO.php
··· 892 892 } 893 893 894 894 895 + public function getPHID() { 896 + return $this->phid; 897 + } 898 + 899 + 895 900 /** 896 901 * Test if a property exists. 897 902 *