Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2895225
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/tokens/query/PhabricatorTokenGivenQuery.php b/src/applications/tokens/query/PhabricatorTokenGivenQuery.php
index c16eaa2168..224efff198 100644
--- a/src/applications/tokens/query/PhabricatorTokenGivenQuery.php
+++ b/src/applications/tokens/query/PhabricatorTokenGivenQuery.php
@@ -1,96 +1,90 @@
<?php
final class PhabricatorTokenGivenQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
private $authorPHIDs;
private $objectPHIDs;
private $tokenPHIDs;
public function withTokenPHIDs(array $token_phids) {
$this->tokenPHIDs = $token_phids;
return $this;
}
public function withObjectPHIDs(array $object_phids) {
$this->objectPHIDs = $object_phids;
return $this;
}
public function withAuthorPHIDs(array $author_phids) {
$this->authorPHIDs = $author_phids;
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;
}
public function getQueryApplicationClass() {
return 'PhabricatorTokensApplication';
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Jan 19 2025, 21:08 (6 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1128770
Default Alt Text
(3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment