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

Allow edge query filtering by destination PHIDs

Summary: See title. Adds features needed for D3136.

Test Plan:
Observe sanity (or run D3136 in a sandbox
and observe that voting works).

Reviewers: epriestley

Reviewed By: epriestley

CC: gmarcotte, aran, Korvin

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

+47
+47
src/infrastructure/edges/query/PhabricatorEdgeQuery.php
··· 38 38 final class PhabricatorEdgeQuery extends PhabricatorQuery { 39 39 40 40 private $sourcePHIDs; 41 + private $destPHIDs; 41 42 private $edgeTypes; 42 43 private $resultSet; 43 44 ··· 58 59 */ 59 60 public function withSourcePHIDs(array $source_phids) { 60 61 $this->sourcePHIDs = $source_phids; 62 + return $this; 63 + } 64 + 65 + 66 + /** 67 + * Find edges terminating at one or more destination PHIDs. 68 + * 69 + * @param list List of destination PHIDs. 70 + * @return this 71 + * 72 + */ 73 + public function withDestinationPHIDs(array $dest_phids) { 74 + $this->destPHIDs = $dest_phids; 61 75 return $this; 62 76 } 63 77 ··· 108 122 ->withEdgeTypes(array($edge_type)) 109 123 ->execute(); 110 124 return array_keys($edges[$src_phid][$edge_type]); 125 + } 126 + 127 + /** 128 + * Convenience method for loading a single edge's metadata for 129 + * a given source, destination, and edge type. Returns null 130 + * if the edge does not exist or does not have metadata. Builds 131 + * and immediately executes a full query. 132 + * 133 + * @param phid Source PHID. 134 + * @param const Edge type. 135 + * @param phid Destination PHID. 136 + * @return wild Edge annotation (or null). 137 + */ 138 + public static function loadSingleEdgeData($src_phid, $edge_type, $dest_phid) { 139 + $edges = id(new PhabricatorEdgeQuery()) 140 + ->withSourcePHIDs(array($src_phid)) 141 + ->withEdgeTypes(array($edge_type)) 142 + ->withDestinationPHIDs(array($dest_phid)) 143 + ->needEdgeData(true) 144 + ->execute(); 145 + 146 + if (isset($edges[$src_phid][$edge_type][$dest_phid]['data'])) { 147 + return $edges[$src_phid][$edge_type][$dest_phid]['data']; 148 + } 149 + return null; 111 150 } 112 151 113 152 ··· 260 299 $conn_r, 261 300 'edge.type IN (%Ls)', 262 301 $this->edgeTypes); 302 + } 303 + 304 + if ($this->destPHIDs) { 305 + // potentially complain if $this->edgeType was not set 306 + $where[] = qsprintf( 307 + $conn_r, 308 + 'edge.dst IN (%Ls)', 309 + $this->destPHIDs); 263 310 } 264 311 265 312 return $this->formatWhereClause($where);