mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
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
This commit is contained in:
parent
77ac52c180
commit
dd21761df9
3 changed files with 20 additions and 3 deletions
|
@ -63,10 +63,16 @@ final class PhabricatorProjectLogicalViewerDatasource
|
||||||
$phids = mpull($projects, 'getPHID');
|
$phids = mpull($projects, 'getPHID');
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach ($phids as $phid) {
|
if ($phids) {
|
||||||
|
foreach ($phids as $phid) {
|
||||||
|
$results[] = new PhabricatorQueryConstraint(
|
||||||
|
PhabricatorQueryConstraint::OPERATOR_OR,
|
||||||
|
$phid);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$results[] = new PhabricatorQueryConstraint(
|
$results[] = new PhabricatorQueryConstraint(
|
||||||
PhabricatorQueryConstraint::OPERATOR_OR,
|
PhabricatorQueryConstraint::OPERATOR_EMPTY,
|
||||||
$phid);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
|
@ -7,6 +7,7 @@ final class PhabricatorQueryConstraint extends Phobject {
|
||||||
const OPERATOR_NOT = 'not';
|
const OPERATOR_NOT = 'not';
|
||||||
const OPERATOR_NULL = 'null';
|
const OPERATOR_NULL = 'null';
|
||||||
const OPERATOR_ANCESTOR = 'ancestor';
|
const OPERATOR_ANCESTOR = 'ancestor';
|
||||||
|
const OPERATOR_EMPTY = 'empty';
|
||||||
|
|
||||||
private $operator;
|
private $operator;
|
||||||
private $value;
|
private $value;
|
||||||
|
|
|
@ -1872,6 +1872,16 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->edgeLogicConstraints as $type => $constraints) {
|
||||||
|
foreach ($constraints as $operator => $list) {
|
||||||
|
switch ($operator) {
|
||||||
|
case PhabricatorQueryConstraint::OPERATOR_EMPTY:
|
||||||
|
throw new PhabricatorEmptyQueryException(
|
||||||
|
pht('This query specifies an empty constraint.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This should probably be more modular, eventually, but we only do
|
// This should probably be more modular, eventually, but we only do
|
||||||
// project-based edge logic today.
|
// project-based edge logic today.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue