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

Don't return any results for viewerprojects() if the viewer is in no projects

Summary:
Fixes T10135. When the viewer is a member of no projects, specify the constraint type as a new "EMPTY" type.

When a query has an "EMPTY" constraint, fail fast with no results.

Test Plan:
- Viewed a viewerprojects() query result set as a user in no projects.
- Before patch: got a lot of hits. After patch: no hits.
- Viewed a normal result set, no changes.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10135

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

+20 -3
+9 -3
src/applications/project/typeahead/PhabricatorProjectLogicalViewerDatasource.php
··· 63 63 $phids = mpull($projects, 'getPHID'); 64 64 65 65 $results = array(); 66 - foreach ($phids as $phid) { 66 + if ($phids) { 67 + foreach ($phids as $phid) { 68 + $results[] = new PhabricatorQueryConstraint( 69 + PhabricatorQueryConstraint::OPERATOR_OR, 70 + $phid); 71 + } 72 + } else { 67 73 $results[] = new PhabricatorQueryConstraint( 68 - PhabricatorQueryConstraint::OPERATOR_OR, 69 - $phid); 74 + PhabricatorQueryConstraint::OPERATOR_EMPTY, 75 + null); 70 76 } 71 77 72 78 return $results;
+1
src/infrastructure/query/constraint/PhabricatorQueryConstraint.php
··· 7 7 const OPERATOR_NOT = 'not'; 8 8 const OPERATOR_NULL = 'null'; 9 9 const OPERATOR_ANCESTOR = 'ancestor'; 10 + const OPERATOR_EMPTY = 'empty'; 10 11 11 12 private $operator; 12 13 private $value;
+10
src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
··· 1872 1872 return $this; 1873 1873 } 1874 1874 1875 + foreach ($this->edgeLogicConstraints as $type => $constraints) { 1876 + foreach ($constraints as $operator => $list) { 1877 + switch ($operator) { 1878 + case PhabricatorQueryConstraint::OPERATOR_EMPTY: 1879 + throw new PhabricatorEmptyQueryException( 1880 + pht('This query specifies an empty constraint.')); 1881 + } 1882 + } 1883 + } 1884 + 1875 1885 // This should probably be more modular, eventually, but we only do 1876 1886 // project-based edge logic today. 1877 1887