@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 HeraldRuleQuery policy-aware

Summary: Ref T2769. dem policy checks

Test Plan: Loaded `/herald/`; loaded rule editor.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2769

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

+15 -27
+1 -1
src/__phutil_library_map__.php
··· 2634 2634 'HeraldRuleEditHistoryController' => 'HeraldController', 2635 2635 'HeraldRuleEditHistoryView' => 'AphrontView', 2636 2636 'HeraldRuleListView' => 'AphrontView', 2637 - 'HeraldRuleQuery' => 'PhabricatorOffsetPagedQuery', 2637 + 'HeraldRuleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 2638 2638 'HeraldTestConsoleController' => 'HeraldController', 2639 2639 'HeraldTranscript' => 'HeraldDAO', 2640 2640 'HeraldTranscriptController' => 'HeraldController',
+2 -1
src/applications/herald/controller/HeraldHomeController.php
··· 26 26 return id(new AphrontRedirectResponse())->setURI($uri); 27 27 } 28 28 29 - $query = new HeraldRuleQuery(); 29 + $query = id(new HeraldRuleQuery()) 30 + ->setViewer($user); 30 31 31 32 $content_type_map = HeraldContentTypeConfig::getContentTypeMap(); 32 33 if (empty($content_type_map[$this->contentType])) {
+4
src/applications/herald/controller/HeraldRuleController.php
··· 540 540 * allows one rule to depend upon the success or failure of another rule. 541 541 */ 542 542 private function loadRulesThisRuleMayDependUpon(HeraldRule $rule) { 543 + $viewer = $this->getRequest()->getUser(); 544 + 543 545 // Any rule can depend on a global rule. 544 546 $all_rules = id(new HeraldRuleQuery()) 547 + ->setViewer($viewer) 545 548 ->withRuleTypes(array(HeraldRuleTypeConfig::RULE_TYPE_GLOBAL)) 546 549 ->withContentTypes(array($rule->getContentType())) 547 550 ->execute(); ··· 549 552 if ($rule->getRuleType() == HeraldRuleTypeConfig::RULE_TYPE_PERSONAL) { 550 553 // Personal rules may depend upon your other personal rules. 551 554 $all_rules += id(new HeraldRuleQuery()) 555 + ->setViewer($viewer) 552 556 ->withRuleTypes(array(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL)) 553 557 ->withContentTypes(array($rule->getContentType())) 554 558 ->withAuthorPHIDs(array($rule->getAuthorPHID()))
+8 -25
src/applications/herald/query/HeraldRuleQuery.php
··· 1 1 <?php 2 2 3 - final class HeraldRuleQuery extends PhabricatorOffsetPagedQuery { 3 + final class HeraldRuleQuery 4 + extends PhabricatorCursorPagedPolicyAwareQuery { 4 5 5 6 private $ids; 6 7 private $phids; 7 8 private $authorPHIDs; 8 9 private $ruleTypes; 9 10 private $contentTypes; 10 - 11 - // TODO: Remove when this becomes policy-aware. 12 - private $viewer; 13 - 14 - public function setViewer($viewer) { 15 - $this->viewer = $viewer; 16 - return $this; 17 - } 18 - 19 - public function getViewer() { 20 - return $this->viewer; 21 - } 22 11 23 12 public function withIDs(array $ids) { 24 13 $this->ids = $ids; ··· 45 34 return $this; 46 35 } 47 36 48 - public function execute() { 37 + public function loadPage() { 49 38 $table = new HeraldRule(); 50 39 $conn_r = $table->establishConnection('r'); 51 40 52 - $where = $this->buildWhereClause($conn_r); 53 - $order = $this->buildOrderClause($conn_r); 54 - $limit = $this->buildLimitClause($conn_r); 55 - 56 41 $data = queryfx_all( 57 42 $conn_r, 58 43 'SELECT rule.* FROM %T rule %Q %Q %Q', 59 44 $table->getTableName(), 60 - $where, 61 - $order, 62 - $limit); 45 + $this->buildWhereClause($conn_r), 46 + $this->buildOrderClause($conn_r), 47 + $this->buildLimitClause($conn_r)); 63 48 64 49 return $table->loadAllFromArray($data); 65 50 } ··· 102 87 $this->contentTypes); 103 88 } 104 89 105 - return $this->formatWhereClause($where); 106 - } 90 + $where[] = $this->buildPagingClause($conn_r); 107 91 108 - private function buildOrderClause($conn_r) { 109 - return 'ORDER BY id DESC'; 92 + return $this->formatWhereClause($where); 110 93 } 111 94 112 95 }