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

Policy - introduce parentQuery and pass around policy configuration from parent to child

Summary: Ref T603. Ref D6941.

Test Plan: Clicked around all over - looked good. I plan to re-test D6941 to make sure the executeOne case works now as intended

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T603

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

+95 -9
+1
src/applications/config/phid/PhabricatorConfigPHIDTypeConfig.php
··· 22 22 23 23 return id(new PhabricatorConfigEntryQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+2 -1
src/applications/conpherence/phid/PhabricatorConpherencePHIDTypeThread.php
··· 24 24 array $phids) { 25 25 26 26 return id(new ConpherenceThreadQuery()) 27 + ->setViewer($query->getViewer()) 28 + ->setParentQuery($query) 27 29 ->withPHIDs($phids) 28 - ->setViewer($query->getViewer()) 29 30 ->execute(); 30 31 } 31 32
+1
src/applications/countdown/phid/PhabricatorCountdownPHIDTypeCountdown.php
··· 22 22 23 23 return id(new PhabricatorCountdownQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/differential/phid/DifferentialPHIDTypeRevision.php
··· 22 22 23 23 return id(new DifferentialRevisionQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/diviner/phid/DivinerPHIDTypeAtom.php
··· 22 22 23 23 return id(new DivinerAtomQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/diviner/phid/DivinerPHIDTypeBook.php
··· 22 22 23 23 return id(new DivinerBookQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/files/phid/PhabricatorFilePHIDTypeFile.php
··· 22 22 23 23 return id(new PhabricatorFileQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/herald/phid/HeraldPHIDTypeRule.php
··· 22 22 23 23 return id(new HeraldRuleQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+3 -2
src/applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php
··· 24 24 array $phids) { 25 25 26 26 return id(new LegalpadDocumentQuery()) 27 + ->setViewer($query->getViewer()) 28 + ->setParentQuery($query) 29 + ->withPHIDs($phids) 27 30 ->needDocumentBodies(true) 28 - ->withPHIDs($phids) 29 - ->setViewer($query->getViewer()) 30 31 ->execute(); 31 32 } 32 33
+1
src/applications/macro/phid/PhabricatorMacroPHIDTypeMacro.php
··· 22 22 23 23 return id(new PhabricatorMacroQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php
··· 22 22 23 23 return id(new PhabricatorMailingListQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/maniphest/phid/ManiphestPHIDTypeTask.php
··· 22 22 23 23 return id(new ManiphestTaskQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php
··· 22 22 23 23 return id(new PhabricatorOwnersPackageQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/paste/phid/PhabricatorPastePHIDTypePaste.php
··· 22 22 23 23 return id(new PhabricatorPasteQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/people/phid/PhabricatorPeoplePHIDTypeExternal.php
··· 22 22 23 23 return id(new PhabricatorExternalAccountQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+3 -2
src/applications/people/phid/PhabricatorPeoplePHIDTypeUser.php
··· 21 21 array $phids) { 22 22 23 23 return id(new PhabricatorPeopleQuery()) 24 + ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 26 + ->withPHIDs($phids) 24 27 ->needProfileImage(true) 25 28 ->needStatus(true) 26 - ->setViewer($query->getViewer()) 27 - ->withPHIDs($phids) 28 29 ->execute(); 29 30 } 30 31
+1
src/applications/phame/phid/PhabricatorPhamePHIDTypeBlog.php
··· 25 25 26 26 return id(new PhameBlogQuery()) 27 27 ->setViewer($query->getViewer()) 28 + ->setParentQuery($query) 28 29 ->withPHIDs($phids) 29 30 ->execute(); 30 31 }
+1
src/applications/phame/phid/PhabricatorPhamePHIDTypePost.php
··· 25 25 26 26 return id(new PhamePostQuery()) 27 27 ->setViewer($query->getViewer()) 28 + ->setParentQuery($query) 28 29 ->withPHIDs($phids) 29 30 ->execute(); 30 31 }
+1
src/applications/phlux/phid/PhluxPHIDTypeVariable.php
··· 22 22 23 23 return id(new PhluxVariableQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/pholio/phid/PholioPHIDTypeImage.php
··· 22 22 23 23 return id(new PholioImageQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/pholio/phid/PholioPHIDTypeMock.php
··· 22 22 23 23 return id(new PholioMockQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/phriction/phid/PhrictionPHIDTypeDocument.php
··· 22 22 23 23 return id(new PhrictionDocumentQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/ponder/phid/PonderPHIDTypeAnswer.php
··· 22 22 23 23 return id(new PonderAnswerQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/ponder/phid/PonderPHIDTypeQuestion.php
··· 22 22 23 23 return id(new PonderQuestionQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/project/phid/PhabricatorProjectPHIDTypeProject.php
··· 22 22 23 23 return id(new PhabricatorProjectQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/releeph/phid/ReleephPHIDTypeBranch.php
··· 22 22 23 23 return id(new ReleephBranchQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/releeph/phid/ReleephPHIDTypeProject.php
··· 22 22 23 23 return id(new ReleephProjectQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/releeph/phid/ReleephPHIDTypeRequest.php
··· 22 22 23 23 return id(new ReleephRequestQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+2
src/applications/repository/phid/PhabricatorRepositoryPHIDTypeArcanistProject.php
··· 23 23 public function loadObjects( 24 24 PhabricatorObjectQuery $query, 25 25 array $phids) { 26 + 26 27 return id(new PhabricatorRepositoryArcanistProjectQuery()) 27 28 ->setViewer($query->getViewer()) 29 + ->setParentQuery($query) 28 30 ->withPHIDs($phids) 29 31 ->execute(); 30 32 }
+1
src/applications/repository/phid/PhabricatorRepositoryPHIDTypeCommit.php
··· 22 22 23 23 return id(new DiffusionCommitQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php
··· 23 23 24 24 return id(new PhabricatorRepositoryQuery()) 25 25 ->setViewer($query->getViewer()) 26 + ->setParentQuery($query) 26 27 ->withPHIDs($phids) 27 28 ->execute(); 28 29 }
+1
src/applications/slowvote/phid/PhabricatorSlowvotePHIDTypePoll.php
··· 22 22 23 23 return id(new PhabricatorSlowvoteQuery()) 24 24 ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 25 26 ->withPHIDs($phids) 26 27 ->execute(); 27 28 }
+1
src/applications/transactions/phid/PhabricatorApplicationTransactionPHIDTypeTransaction.php
··· 57 57 58 58 $xactions = id(clone $query) 59 59 ->setViewer($object_query->getViewer()) 60 + ->setParentQuery($object_query) 60 61 ->withPHIDs($subtype_phids) 61 62 ->execute(); 62 63
+56 -4
src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php
··· 30 30 31 31 private $viewer; 32 32 private $raisePolicyExceptions; 33 + private $parentQuery; 33 34 private $rawResultLimit; 34 35 private $capabilities; 35 36 ··· 64 65 65 66 66 67 /** 68 + * Set the parent query of this query. This is useful for nested queries so 69 + * that configuration like whether or not to raise policy exceptions is 70 + * seamlessly passed along to child queries. 71 + * 72 + * @return this 73 + * @task config 74 + */ 75 + final public function setParentQuery(PhabricatorPolicyAwareQuery $query) { 76 + $this->parentQuery = $query; 77 + return $this; 78 + } 79 + 80 + 81 + /** 82 + * Get the parent query. See @{method:setParentQuery} for discussion. 83 + * 84 + * @return PhabricatorPolicyAwareQuery The parent query. 85 + * @task config 86 + */ 87 + final public function getParentQuery() { 88 + return $this->parentQuery; 89 + } 90 + 91 + 92 + /** 93 + * Hook to configure whether this query should raise policy exceptions. 94 + * 95 + * @return this 96 + * @task config 97 + */ 98 + final public function setRaisePolicyExceptions($bool) { 99 + $this->raisePolicyExceptions = $bool; 100 + return $this; 101 + } 102 + 103 + 104 + /** 105 + * @return bool 106 + * @task config 107 + */ 108 + final public function shouldRaisePolicyExceptions() { 109 + return (bool) $this->raisePolicyExceptions; 110 + } 111 + 112 + 113 + /** 67 114 * @task config 68 115 */ 69 116 final public function requireCapabilities(array $capabilities) { ··· 89 136 * } 90 137 * 91 138 * If zero results match the query, this method returns `null`. 92 - * 93 139 * If one result matches the query, this method returns that result. 94 140 * 95 141 * If two or more results match the query, this method throws an exception. ··· 105 151 */ 106 152 final public function executeOne() { 107 153 108 - $this->raisePolicyExceptions = true; 154 + $this->setRaisePolicyExceptions(true); 109 155 try { 110 156 $results = $this->execute(); 111 157 } catch (Exception $ex) { 112 - $this->raisePolicyExceptions = false; 158 + $this->setRaisePolicyExceptions(false); 113 159 throw $ex; 114 160 } 115 161 ··· 136 182 throw new Exception("Call setViewer() before execute()!"); 137 183 } 138 184 185 + $parent_query = $this->getParentQuery(); 186 + if ($parent_query) { 187 + $this->setRaisePolicyExceptions( 188 + $parent_query->shouldRaisePolicyExceptions()); 189 + } 190 + 139 191 $results = array(); 140 192 141 193 $filter = new PhabricatorPolicyFilter(); ··· 149 201 $capabilities = $this->capabilities; 150 202 } 151 203 $filter->requireCapabilities($capabilities); 152 - $filter->raisePolicyExceptions($this->raisePolicyExceptions); 204 + $filter->raisePolicyExceptions($this->shouldRaisePolicyExceptions()); 153 205 154 206 $offset = (int)$this->getOffset(); 155 207 $limit = (int)$this->getLimit();