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

Clean up ProjectQuery when viewer is logged-out or omnipotent

Summary:
Ref T10010. When the viewer is logged-out or omnipotent, we can skip this query.

(Currently we issue a silly query like `src = X AND type = Y AND dst = ''`, which will never return results.)

Test Plan:
- Viewed projects as normal user and logged-out user.
- Ran unit tests.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10010

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

+19 -5
+19 -5
src/applications/project/query/PhabricatorProjectQuery.php
··· 226 226 227 227 // If we only need to know if the viewer is a member, we can restrict 228 228 // the query to just their PHID. 229 + $any_edges = true; 229 230 if (!$this->needMembers && !$this->needWatchers) { 230 - $edge_query->withDestinationPHIDs(array($viewer_phid)); 231 + if ($viewer_phid) { 232 + $edge_query->withDestinationPHIDs(array($viewer_phid)); 233 + } else { 234 + // If we don't need members or watchers and don't have a viewer PHID 235 + // (viewer is logged-out or omnipotent), they'll never be a member 236 + // so we don't need to issue this query at all. 237 + $any_edges = false; 238 + } 231 239 } 232 240 233 - $edge_query->execute(); 241 + if ($any_edges) { 242 + $edge_query->execute(); 243 + } 234 244 235 245 $membership_projects = array(); 236 246 foreach ($projects as $project) { ··· 242 252 $source_phids = array($project_phid); 243 253 } 244 254 245 - $member_phids = $edge_query->getDestinationPHIDs( 246 - $source_phids, 247 - array($member_type)); 255 + if ($any_edges) { 256 + $member_phids = $edge_query->getDestinationPHIDs( 257 + $source_phids, 258 + array($member_type)); 259 + } else { 260 + $member_phids = array(); 261 + } 248 262 249 263 if (in_array($viewer_phid, $member_phids)) { 250 264 $membership_projects[$project_phid] = $project;