Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable' into easypost-patches
Browse files Browse the repository at this point in the history
  • Loading branch information
Roguelazer committed Mar 25, 2019
2 parents 453ab73 + d3df0a4 commit 971b50e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
34 changes: 23 additions & 11 deletions src/applications/conpherence/query/ConpherenceThreadQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,23 +285,35 @@ private function loadCoreHandles(
}

private function loadTransactionsAndHandles(array $conpherences) {
$query = id(new ConpherenceTransactionQuery())
->setViewer($this->getViewer())
->withObjectPHIDs(array_keys($conpherences))
->needHandles(true);
// NOTE: This is older code which has been modernized to the minimum
// standard required by T13266. It probably isn't the best available
// approach to the problems it solves.

$limit = $this->getTransactionLimit();
if ($limit) {
// fetch an extra for "show older" scenarios
$limit = $limit + 1;
} else {
$limit = 0xFFFF;
}

$pager = id(new AphrontCursorPagerView())
->setPageSize($limit);

// We have to flip these for the underlying query class. The semantics of
// paging are tricky business.
if ($this->afterTransactionID) {
$query->setBeforeID($this->afterTransactionID);
$pager->setBeforeID($this->afterTransactionID);
} else if ($this->beforeTransactionID) {
$query->setAfterID($this->beforeTransactionID);
$pager->setAfterID($this->beforeTransactionID);
}
if ($this->getTransactionLimit()) {
// fetch an extra for "show older" scenarios
$query->setLimit($this->getTransactionLimit() + 1);
}
$transactions = $query->execute();

$transactions = id(new ConpherenceTransactionQuery())
->setViewer($this->getViewer())
->withObjectPHIDs(array_keys($conpherences))
->needHandles(true)
->executeWithCursorPager($pager);

$transactions = mgroup($transactions, 'getObjectPHID');
foreach ($conpherences as $phid => $conpherence) {
$current_transactions = idx($transactions, $phid, array());
Expand Down
15 changes: 11 additions & 4 deletions src/applications/phame/controller/post/PhamePostViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,26 @@ private function buildCommentForm(PhamePost $post, $timeline) {
private function loadAdjacentPosts(PhamePost $post) {
$viewer = $this->getViewer();

$pager = id(new AphrontCursorPagerView())
->setPageSize(1);

$prev_pager = id(clone $pager)
->setAfterID($post->getID());

$next_pager = id(clone $pager)
->setBeforeID($post->getID());

$query = id(new PhamePostQuery())
->setViewer($viewer)
->withVisibility(array(PhameConstants::VISIBILITY_PUBLISHED))
->withBlogPHIDs(array($post->getBlog()->getPHID()))
->setLimit(1);

$prev = id(clone $query)
->setAfterID($post->getID())
->execute();
->executeWithCursorPager($prev_pager);

$next = id(clone $query)
->setBeforeID($post->getID())
->execute();
->executeWithCursorPager($next_pager);

return array(head($prev), head($next));
}
Expand Down

0 comments on commit 971b50e

Please sign in to comment.