Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15335445
D18027.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D18027.diff
View Options
diff --git a/src/applications/feed/conduit/FeedQueryConduitAPIMethod.php b/src/applications/feed/conduit/FeedQueryConduitAPIMethod.php
--- a/src/applications/feed/conduit/FeedQueryConduitAPIMethod.php
+++ b/src/applications/feed/conduit/FeedQueryConduitAPIMethod.php
@@ -67,16 +67,16 @@
if (!$limit) {
$limit = $this->getDefaultLimit();
}
- $filter_phids = $request->getValue('filterPHIDs');
- if (!$filter_phids) {
- $filter_phids = array();
- }
$query = id(new PhabricatorFeedQuery())
->setLimit($limit)
- ->setFilterPHIDs($filter_phids)
->setViewer($user);
+ $filter_phids = $request->getValue('filterPHIDs');
+ if ($filter_phids) {
+ $query->withFilterPHIDs($filter_phids);
+ }
+
$after = $request->getValue('after');
if (strlen($after)) {
$query->setAfterID($after);
diff --git a/src/applications/feed/query/PhabricatorFeedQuery.php b/src/applications/feed/query/PhabricatorFeedQuery.php
--- a/src/applications/feed/query/PhabricatorFeedQuery.php
+++ b/src/applications/feed/query/PhabricatorFeedQuery.php
@@ -6,7 +6,7 @@
private $filterPHIDs;
private $chronologicalKeys;
- public function setFilterPHIDs(array $phids) {
+ public function withFilterPHIDs(array $phids) {
$this->filterPHIDs = $phids;
return $this;
}
@@ -16,50 +16,46 @@
return $this;
}
- protected function loadPage() {
- $story_table = new PhabricatorFeedStoryData();
- $conn = $story_table->establishConnection('r');
+ public function newResultObject() {
+ return new PhabricatorFeedStoryData();
+ }
- $data = queryfx_all(
- $conn,
- 'SELECT story.* FROM %T story %Q %Q %Q %Q %Q',
- $story_table->getTableName(),
- $this->buildJoinClause($conn),
- $this->buildWhereClause($conn),
- $this->buildGroupClause($conn),
- $this->buildOrderClause($conn),
- $this->buildLimitClause($conn));
-
- return $data;
+ protected function loadPage() {
+ // NOTE: We return raw rows from this method, which is a little unusual.
+ return $this->loadStandardPageRows($this->newResultObject());
}
protected function willFilterPage(array $data) {
return PhabricatorFeedStory::loadAllFromRows($data, $this->getViewer());
}
- protected function buildJoinClause(AphrontDatabaseConnection $conn_r) {
+ protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {
+ $joins = parent::buildJoinClauseParts($conn);
+
// NOTE: We perform this join unconditionally (even if we have no filter
// PHIDs) to omit rows which have no story references. These story data
// rows are notifications or realtime alerts.
$ref_table = new PhabricatorFeedStoryReference();
- return qsprintf(
- $conn_r,
+ $joins[] = qsprintf(
+ $conn,
'JOIN %T ref ON ref.chronologicalKey = story.chronologicalKey',
$ref_table->getTableName());
+
+ return $joins;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
- if ($this->filterPHIDs) {
+ if ($this->filterPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'ref.objectPHID IN (%Ls)',
$this->filterPHIDs);
}
- if ($this->chronologicalKeys) {
+ if ($this->chronologicalKeys !== null) {
// NOTE: We want to use integers in the query so we can take advantage
// of keys, but can't use %d on 32-bit systems. Make sure all the keys
// are integers and then format them raw.
@@ -73,21 +69,19 @@
}
$where[] = qsprintf(
- $conn_r,
+ $conn,
'ref.chronologicalKey IN (%Q)',
implode(', ', $keys));
}
- $where[] = $this->buildPagingClause($conn_r);
-
- return $this->formatWhereClause($where);
+ return $where;
}
- protected function buildGroupClause(AphrontDatabaseConnection $conn_r) {
- if ($this->filterPHIDs) {
- return qsprintf($conn_r, 'GROUP BY ref.chronologicalKey');
+ protected function buildGroupClause(AphrontDatabaseConnection $conn) {
+ if ($this->filterPHIDs !== null) {
+ return qsprintf($conn, 'GROUP BY ref.chronologicalKey');
} else {
- return qsprintf($conn_r, 'GROUP BY story.chronologicalKey');
+ return qsprintf($conn, 'GROUP BY story.chronologicalKey');
}
}
@@ -120,6 +114,10 @@
return $item['chronologicalKey'];
}
+ protected function getPrimaryTableAlias() {
+ return 'story';
+ }
+
public function getQueryApplicationClass() {
return 'PhabricatorFeedApplication';
}
diff --git a/src/applications/feed/query/PhabricatorFeedSearchEngine.php b/src/applications/feed/query/PhabricatorFeedSearchEngine.php
--- a/src/applications/feed/query/PhabricatorFeedSearchEngine.php
+++ b/src/applications/feed/query/PhabricatorFeedSearchEngine.php
@@ -56,7 +56,7 @@
$phids = array_mergev($phids);
if ($phids) {
- $query->setFilterPHIDs($phids);
+ $query->withFilterPHIDs($phids);
}
return $query;
diff --git a/src/applications/people/controller/PhabricatorPeopleProfileViewController.php b/src/applications/people/controller/PhabricatorPeopleProfileViewController.php
--- a/src/applications/people/controller/PhabricatorPeopleProfileViewController.php
+++ b/src/applications/people/controller/PhabricatorPeopleProfileViewController.php
@@ -229,7 +229,7 @@
$viewer) {
$query = new PhabricatorFeedQuery();
- $query->setFilterPHIDs(
+ $query->withFilterPHIDs(
array(
$user->getPHID(),
));
diff --git a/src/applications/project/controller/PhabricatorProjectProfileController.php b/src/applications/project/controller/PhabricatorProjectProfileController.php
--- a/src/applications/project/controller/PhabricatorProjectProfileController.php
+++ b/src/applications/project/controller/PhabricatorProjectProfileController.php
@@ -73,7 +73,7 @@
$stories = id(new PhabricatorFeedQuery())
->setViewer($viewer)
- ->setFilterPHIDs(
+ ->withFilterPHIDs(
array(
$project->getPHID(),
))
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 9, 3:26 PM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7384937
Default Alt Text
D18027.diff (6 KB)
Attached To
Mode
D18027: Modernize FeedQuery a little bit
Attached
Detach File
Event Timeline
Log In to Comment