Formatting Query Clauses
- protected function formatWhereClause($conn, $parts)
- protected function formatSelectClause($conn, $parts)
- protected function formatJoinClause($conn, $parts)
- protected function formatHavingClause($conn, $parts)
- private function flattenSubclause($parts)
Query Configuration
- final public function setViewer($viewer) — Set the viewer who is executing the query. Results will be filtered according to the viewer's capabilities. You must set a viewer to execute a policy query.
- final public function getViewer() — Get the query's viewer.
- final public function setParentQuery($query) — Set the parent query of this query. This is useful for nested queries so that configuration like whether or not to raise policy exceptions is seamlessly passed along to child queries.
- final public function getParentQuery() — Get the parent query. See @{method:setParentQuery} for discussion.
- final public function setRaisePolicyExceptions($bool) — Hook to configure whether this query should raise policy exceptions.
- final public function shouldRaisePolicyExceptions()
- final public function requireCapabilities($capabilities)
Executing Queries
- final public function execute() — Execute the query, loading all visible results.
- final public function executeOne() — Execute the query, expecting a single result. This method simplifies loading objects for detail pages or edit views.
- public function getPolicyFilteredPHIDs() — Return a map of all object PHIDs which were loaded in the query but filtered out by policy constraints. This allows a caller to distinguish between objects which do not exist (or, at least, were filtered at the content level) and objects which exist but aren't visible.
Policy Query Implementation
- final protected function getRawResultLimit() — Get the number of results @{method:loadPage} should load. If the value is 0, @{method:loadPage} should load all available results.
- protected function willExecute() — Hook invoked before query execution. Generally, implementations should reset any internal cursors.
- abstract protected function loadPage() — Load a raw page of results. Generally, implementations should load objects from the database. They should attempt to return the number of results hinted by @{method:getRawResultLimit}.
- abstract protected function nextPage($page) — Update internal state so that the next call to @{method:loadPage} will return new results. Generally, you should adjust a cursor position based on the provided result page.
- protected function willFilterPage($page) — Hook for applying a page filter prior to the privacy filter. This allows you to drop some items from the result set without creating problems with pagination or cursor updates. You can also load and attach data which is required to perform policy filtering.
- protected function didFilterResults($results) — Hook for removing filtered results from alternate result sets. This hook will be called with any objects which were returned by the query but filtered for policy reasons. The query should remove them from any cached or partial result sets.
- protected function didLoadResults($results) — Hook for applying final adjustments before results are returned. This is used by @{class:PhabricatorCursorPagedPolicyAwareQuery} to reverse results that are queried during reverse paging.
- protected function shouldDisablePolicyFiltering() — Allows a subclass to disable policy filtering. This method is dangerous. It should be used only if the query loads data which has already been filtered (for example, because it wraps some other query which uses normal policy filtering).
Other Methods
- final public function setOffset($offset)
- final public function setLimit($limit)
- final public function getOffset()
- final public function getLimit()
- protected function buildLimitClause($conn)
- final public function executeWithOffsetPager($pager)
- final public function setReturnPartialResultsOnOverheat($bool)
- final public function setDisableOverheating($disable_overheating)
- private function getPolicyFilter()
- protected function getRequiredCapabilities()
- protected function applyPolicyFilter($objects, $capabilities)
- protected function didRejectResult($object)
- public function addPolicyFilteredPHIDs($phids)
- public function getIsOverheated()
- public function putPHIDsInFlight($phids) — Mark PHIDs as in flight.
- public function getPHIDsInFlight() — Get PHIDs which are currently in flight.
- protected function didFilterPage($page) — Hook for performing additional non-policy loading or filtering after an object has satisfied all policy checks. Generally, this means loading and attaching related data.
- abstract public function getQueryApplicationClass() — If this query belongs to an application, return the application class name here. This will prevent the query from returning results if the viewer can not access the application.
- public function canViewerUseQueryApplication() — Determine if the viewer has permission to use this query's application. For queries which aren't part of an application, this method always returns true.
- private function applyWillFilterPageExtensions($page)
workspace
- public function putObjectsInWorkspace($objects) — Put a map of objects into the query workspace. Many queries perform subqueries, which can eventually end up loading the same objects more than once (often to perform policy checks).
- public function getObjectsFromWorkspace($phids) — Retrieve objects from the query workspace. For more discussion about the workspace mechanism, see @{method:putObjectsInWorkspace}. This method searches both the current query's workspace and the workspaces of parent queries.