@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorQueryIterator extends PhutilBufferedIterator {
4
5 private $query;
6 private $pager;
7
8 public function __construct(PhabricatorCursorPagedPolicyAwareQuery $query) {
9 $this->query = $query;
10 }
11
12 protected function didRewind() {
13 $pager = new AphrontCursorPagerView();
14
15 $page_size = $this->getPageSize();
16 $pager->setPageSize($page_size);
17
18 $this->pager = $pager;
19 }
20
21 #[\ReturnTypeWillChange]
22 public function key() {
23 return $this->current()->getID();
24 }
25
26 protected function loadPage() {
27 if (!$this->pager) {
28 return array();
29 }
30
31 $pager = clone $this->pager;
32 $query = clone $this->query;
33
34 $query->setDisableOverheating(true);
35
36 $results = $query->executeWithCursorPager($pager);
37
38 // If we got less than a full page of results, this was the last set of
39 // results. Throw away the pager so we end iteration.
40 if (!$pager->getHasMoreResults()) {
41 $this->pager = null;
42 } else {
43 $this->pager->setAfterID($pager->getNextPageID());
44 }
45
46 return $results;
47 }
48
49}