From b0b8926c7564ea206c0a03e54bcebf6913724018 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 22 Apr 2019 10:39:08 -0700 Subject: [PATCH] Fix "before/after" cursor paging for API call "feed.query" Summary: Ref T13266. See . This older API call needs an update to the newer paging/cursor API. Test Plan: Called `feed.query` with an "after" parameter. Reviewers: amckinley Reviewed By: amckinley Subscribers: Itms Maniphest Tasks: T13266 Differential Revision: https://secure.phabricator.com/D20456 --- .../conduit/FeedQueryConduitAPIMethod.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/applications/feed/conduit/FeedQueryConduitAPIMethod.php b/src/applications/feed/conduit/FeedQueryConduitAPIMethod.php index bddc4f5921..53f3fe8f39 100644 --- a/src/applications/feed/conduit/FeedQueryConduitAPIMethod.php +++ b/src/applications/feed/conduit/FeedQueryConduitAPIMethod.php @@ -63,13 +63,7 @@ final class FeedQueryConduitAPIMethod extends FeedConduitAPIMethod { $view_type = 'data'; } - $limit = $request->getValue('limit'); - if (!$limit) { - $limit = $this->getDefaultLimit(); - } - $query = id(new PhabricatorFeedQuery()) - ->setLimit($limit) ->setViewer($user); $filter_phids = $request->getValue('filterPHIDs'); @@ -77,17 +71,25 @@ final class FeedQueryConduitAPIMethod extends FeedConduitAPIMethod { $query->withFilterPHIDs($filter_phids); } + $limit = $request->getValue('limit'); + if (!$limit) { + $limit = $this->getDefaultLimit(); + } + + $pager = id(new AphrontCursorPagerView()) + ->setPageSize($limit); + $after = $request->getValue('after'); if (strlen($after)) { - $query->setAfterID($after); + $pager->setAfterID($after); } $before = $request->getValue('before'); if (strlen($before)) { - $query->setBeforeID($before); + $pager->setBeforeID($before); } - $stories = $query->execute(); + $stories = $query->executeWithCursorPager($pager); if ($stories) { foreach ($stories as $story) {