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

Fix an issue where loading a mangled project graph could fail too abruptly

Summary:
Ref T13484. If you load a subproject S which has a mangled/invalid `parentPath`, the query currently tries to execute an empty edge query and fatals.

Instead, we want to deny-by-default in the policy layer but not fail the query. The subproject should become restricted but not fatal anything related to it.

See T13484 for a future refinement where we could identify "broken / data integrity issue" objects explicilty.

Test Plan:
- Modified the `projectPath` of some subproject in the database to `QQQQ...`.
- Loaded that project page.
- Before patch: fatal after issuing bad edge query.
- After patch: "functionally correct" policy layer failure, although an explicit "data integrity issue" failure would be better.

Maniphest Tasks: T13484

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

+28 -3
+19
src/applications/project/query/PhabricatorProjectQuery.php
··· 271 271 272 272 $all_graph = $this->getAllReachableAncestors($projects); 273 273 274 + // See T13484. If the graph is damaged (and contains a cycle or an edge 275 + // pointing at a project which has been destroyed), some of the nodes we 276 + // started with may be filtered out by reachability tests. If any of the 277 + // projects we are linking up don't have available ancestors, filter them 278 + // out. 279 + 280 + foreach ($projects as $key => $project) { 281 + $project_phid = $project->getPHID(); 282 + if (!isset($all_graph[$project_phid])) { 283 + $this->didRejectResult($project); 284 + unset($projects[$key]); 285 + continue; 286 + } 287 + } 288 + 289 + if (!$projects) { 290 + return array(); 291 + } 292 + 274 293 // NOTE: Although we may not need much information about ancestors, we 275 294 // always need to test if the viewer is a member, because we will return 276 295 // ancestor projects to the policy filter via ExtendedPolicy calls. If
+9 -3
src/infrastructure/edges/query/PhabricatorEdgeQuery.php
··· 46 46 * @task config 47 47 */ 48 48 public function withSourcePHIDs(array $source_phids) { 49 + if (!$source_phids) { 50 + throw new Exception( 51 + pht( 52 + 'Edge list passed to "withSourcePHIDs(...)" is empty, but it must '. 53 + 'be nonempty.')); 54 + } 55 + 49 56 $this->sourcePHIDs = $source_phids; 50 57 return $this; 51 58 } ··· 158 165 * @task exec 159 166 */ 160 167 public function execute() { 161 - if (!$this->sourcePHIDs) { 168 + if ($this->sourcePHIDs === null) { 162 169 throw new Exception( 163 170 pht( 164 - 'You must use %s to query edges.', 165 - 'withSourcePHIDs()')); 171 + 'You must use "withSourcePHIDs()" to query edges.')); 166 172 } 167 173 168 174 $sources = phid_group_by_type($this->sourcePHIDs);