@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.

Call didRejectResult() in DiffusionCommitQuery properly

Summary:
Ref T4345. This error is per object-type in the query implementations, not a mail/permissions issue.

Without `didRejectResult()`, we can't distinguish between "restricted" and "unknown" for objects filtered by `willFilterPage()`.

- Call `didRejectResult()` on commits.
- Make `didRejectResult()` handle both existing policy exceptions and filtering.
- Recover from partial objects (like commits) which are missing attached data required to figure out policies.

Test Plan: Saw "Restricted Diffusion Commit" instead of "Unknown Object (Diffusion Commit)" when viewing nonvisible commit handle in Maniphest.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T4345

Differential Revision: https://secure.phabricator.com/D13289

+18 -1
+1
src/applications/diffusion/query/DiffusionCommitQuery.php
··· 193 193 if ($repo) { 194 194 $commit->attachRepository($repo); 195 195 } else { 196 + $this->didRejectResult($commit); 196 197 unset($commits[$key]); 197 198 continue; 198 199 }
+17 -1
src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php
··· 338 338 } 339 339 340 340 protected function didRejectResult(PhabricatorPolicyInterface $object) { 341 + // Some objects (like commits) may be rejected because related objects 342 + // (like repositories) can not be loaded. In some cases, we may need these 343 + // related objects to determine the object policy, so it's expected that 344 + // we may occasionally be unable to determine the policy. 345 + 346 + try { 347 + $policy = $object->getPolicy(PhabricatorPolicyCapability::CAN_VIEW); 348 + } catch (Exception $ex) { 349 + $policy = null; 350 + } 351 + 352 + // Mark this object as filtered so handles can render "Restricted" instead 353 + // of "Unknown". 354 + $phid = $object->getPHID(); 355 + $this->addPolicyFilteredPHIDs(array($phid => $phid)); 356 + 341 357 $this->getPolicyFilter()->rejectObject( 342 358 $object, 343 - $object->getPolicy(PhabricatorPolicyCapability::CAN_VIEW), 359 + $policy, 344 360 PhabricatorPolicyCapability::CAN_VIEW); 345 361 } 346 362