Page MenuHomePhabricator

D14905.id36025.diff
No OneTemporary

D14905.id36025.diff

diff --git a/src/applications/tokens/query/PhabricatorTokenGivenQuery.php b/src/applications/tokens/query/PhabricatorTokenGivenQuery.php
--- a/src/applications/tokens/query/PhabricatorTokenGivenQuery.php
+++ b/src/applications/tokens/query/PhabricatorTokenGivenQuery.php
@@ -22,68 +22,62 @@
return $this;
}
+ public function newResultObject() {
+ return new PhabricatorTokenGiven();
+ }
+
protected function loadPage() {
- $table = new PhabricatorTokenGiven();
- $conn_r = $table->establishConnection('r');
-
- $rows = queryfx_all(
- $conn_r,
- 'SELECT * FROM %T %Q %Q %Q',
- $table->getTableName(),
- $this->buildWhereClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- return $table->loadAllFromArray($rows);
+ return $this->loadStandardPage($this->newResultObject());
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
- if ($this->authorPHIDs) {
+ if ($this->authorPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'authorPHID IN (%Ls)',
$this->authorPHIDs);
}
- if ($this->objectPHIDs) {
+ if ($this->objectPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'objectPHID IN (%Ls)',
$this->objectPHIDs);
}
- if ($this->tokenPHIDs) {
+ if ($this->tokenPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'tokenPHID IN (%Ls)',
$this->tokenPHIDs);
}
- $where[] = $this->buildPagingClause($conn_r);
-
- return $this->formatWhereClause($where);
+ return $where;
}
protected function willFilterPage(array $results) {
- $object_phids = array_filter(mpull($results, 'getObjectPHID'));
- if (!$object_phids) {
- return array();
- }
+ $object_phids = mpull($results, 'getObjectPHID');
$objects = id(new PhabricatorObjectQuery())
->setViewer($this->getViewer())
->withPHIDs($object_phids)
->execute();
+ $objects = mpull($objects, null, 'getPHID');
foreach ($results as $key => $result) {
- $phid = $result->getObjectPHID();
- if (empty($objects[$phid])) {
- unset($results[$key]);
- } else {
- $result->attachObject($objects[$phid]);
+ $object = idx($objects, $result->getObjectPHID());
+
+ if ($object) {
+ if ($object instanceof PhabricatorTokenReceiverInterface) {
+ $result->attachObject($object);
+ continue;
+ }
}
+
+ $this->didRejectResult($result);
+ unset($results[$key]);
}
return $results;

File Metadata

Mime Type
text/plain
Expires
Wed, Mar 19, 10:08 PM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7712089
Default Alt Text
D14905.id36025.diff (2 KB)

Event Timeline