Implement PhrictionDocumentQuery

Summary:
Companion for D5284. Move all the query logic to a policy-aware query class. In particular:

  - Currently, anyone can view and edit a project's wiki documents. For callsites using this query class, you must be able to view or edit the project to view or edit its documents.
  - There's some very sketchy logic with the content/document joins. This cleans that up.
  - This cleans up loading projects by moving it inside the query. We need to do this anyway to perform policy checks.

Test Plan: Viewed active/all/updated. Set page size to 2, verified pager works.

Reviewers: AnhNhan, chad

Reviewed By: AnhNhan

CC: aran

Differential Revision: https://secure.phabricator.com/D5285
This commit is contained in:
epriestley
2013-03-08 07:12:24 -08:00
parent 06b3f21b61
commit b799f5671b
5 changed files with 240 additions and 72 deletions

View File

@@ -6,6 +6,7 @@ final class PhabricatorProjectQuery
private $ids;
private $phids;
private $memberPHIDs;
private $slugs;
private $status = 'status-any';
const STATUS_ANY = 'status-any';
@@ -36,6 +37,11 @@ final class PhabricatorProjectQuery
return $this;
}
public function withPhrictionSlugs(array $slugs) {
$this->slugs = $slugs;
return $this;
}
public function needMembers($need_members) {
$this->needMembers = $need_members;
return $this;
@@ -155,6 +161,13 @@ final class PhabricatorProjectQuery
$this->memberPHIDs);
}
if ($this->slugs) {
$where[] = qsprintf(
$conn_r,
'phrictionSlug IN (%Ls)',
$this->slugs);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);