@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 47 lines 989 B view raw
1<?php 2 3/** 4 * Iterate over every object of a given type, without holding all of them in 5 * memory. This is useful for performing database migrations. 6 * 7 * $things = new LiskMigrationIterator(new LiskThing()); 8 * foreach ($things as $thing) { 9 * // do something 10 * } 11 * 12 * NOTE: This only works on objects with a normal `id` column. 13 * 14 * @task storage 15 */ 16final class LiskMigrationIterator extends PhutilBufferedIterator { 17 18 private $object; 19 private $cursor; 20 21 public function __construct(LiskDAO $object) { 22 $this->object = $object; 23 } 24 25 protected function didRewind() { 26 $this->cursor = 0; 27 } 28 29 #[\ReturnTypeWillChange] 30 public function key() { 31 return $this->current()->getID(); 32 } 33 34 protected function loadPage() { 35 $results = $this->object->loadAllWhere( 36 'id > %d ORDER BY id ASC LIMIT %d', 37 $this->cursor, 38 $this->getPageSize()); 39 40 if ($results) { 41 $this->cursor = last($results)->getID(); 42 } 43 44 return $results; 45 } 46 47}