@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
at upstream/main 76 lines 1.7 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorSavedQuery> 5 */ 6final class PhabricatorSavedQueryQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $ids; 10 private $engineClassNames; 11 private $queryKeys; 12 13 public function withIDs(array $ids) { 14 $this->ids = $ids; 15 return $this; 16 } 17 18 public function withEngineClassNames(array $engine_class_names) { 19 $this->engineClassNames = $engine_class_names; 20 return $this; 21 } 22 23 public function withQueryKeys(array $query_keys) { 24 $this->queryKeys = $query_keys; 25 return $this; 26 } 27 28 protected function loadPage() { 29 $table = new PhabricatorSavedQuery(); 30 $conn_r = $table->establishConnection('r'); 31 32 $data = queryfx_all( 33 $conn_r, 34 'SELECT * FROM %T %Q %Q %Q', 35 $table->getTableName(), 36 $this->buildWhereClause($conn_r), 37 $this->buildOrderClause($conn_r), 38 $this->buildLimitClause($conn_r)); 39 40 return $table->loadAllFromArray($data); 41 } 42 43 protected function buildWhereClause(AphrontDatabaseConnection $conn) { 44 $where = array(); 45 46 if ($this->ids !== null) { 47 $where[] = qsprintf( 48 $conn, 49 'id IN (%Ld)', 50 $this->ids); 51 } 52 53 if ($this->engineClassNames !== null) { 54 $where[] = qsprintf( 55 $conn, 56 'engineClassName IN (%Ls)', 57 $this->engineClassNames); 58 } 59 60 if ($this->queryKeys !== null) { 61 $where[] = qsprintf( 62 $conn, 63 'queryKey IN (%Ls)', 64 $this->queryKeys); 65 } 66 67 $where[] = $this->buildPagingClause($conn); 68 69 return $this->formatWhereClause($conn, $where); 70 } 71 72 public function getQueryApplicationClass() { 73 return PhabricatorSearchApplication::class; 74 } 75 76}