Index: src/applications/policy/query/PhabricatorPolicyQuery.php =================================================================== --- src/applications/policy/query/PhabricatorPolicyQuery.php +++ src/applications/policy/query/PhabricatorPolicyQuery.php @@ -1,16 +1,11 @@ viewer = $viewer; - return $this; - } - public function setObject(PhabricatorPolicyInterface $object) { $this->object = $object; return $this; @@ -58,11 +53,7 @@ return $policies; } - public function execute() { - if (!$this->viewer) { - throw new Exception('Call setViewer() before execute()!'); - } - + public function loadPage() { if ($this->object && $this->phids) { throw new Exception( "You can not issue a policy query with both setObject() and ". @@ -102,7 +93,7 @@ if ($handle_policies) { $handles = id(new PhabricatorHandleQuery()) - ->setViewer($this->viewer) + ->setViewer($this->getViewer()) ->withPHIDs($handle_policies) ->execute(); foreach ($handle_policies as $phid) { @@ -179,11 +170,12 @@ private function loadObjectPolicyPHIDs() { $phids = array(); + $viewer = $this->getViewer(); - if ($this->viewer->getPHID()) { + if ($viewer->getPHID()) { $projects = id(new PhabricatorProjectQuery()) - ->setViewer($this->viewer) - ->withMemberPHIDs(array($this->viewer->getPHID())) + ->setViewer($viewer) + ->withMemberPHIDs(array($viewer->getPHID())) ->execute(); foreach ($projects as $project) { $phids[] = $project->getPHID(); @@ -215,5 +207,11 @@ return $phids; } + protected function shouldDisablePolicyFiltering() { + // Policy filtering of policies is currently perilous and not required by + // the application. + return true; + } + } Index: src/applications/policy/storage/PhabricatorPolicy.php =================================================================== --- src/applications/policy/storage/PhabricatorPolicy.php +++ src/applications/policy/storage/PhabricatorPolicy.php @@ -1,7 +1,8 @@ assertAttached($this->ruleObjects); } + +/* -( PhabricatorPolicyInterface )----------------------------------------- */ + + + public function getCapabilities() { + return array( + PhabricatorPolicyCapability::CAN_VIEW, + ); + } + + public function getPolicy($capability) { + // NOTE: We implement policies only so we can comply with the interface. + // The actual query skips them, as enforcing policies on policies seems + // perilous and isn't currently required by the application. + return PhabricatorPolicies::POLICY_PUBLIC; + } + + public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { + return false; + } + + public function describeAutomaticCapability($capability) { + return null; + } + }