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

Allow ApplicationSearch to be offset-paged

Summary: Ref T4365. It's not practical to cursor-page all engines; allow main search engines to be offset-paged. Basically, this comes down to setting a flag and then doing a couple of tiny things differently.

Test Plan: Used this two diffs from now.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4365

Differential Revision: https://secure.phabricator.com/D8121

+38 -13
+24 -3
src/applications/search/controller/PhabricatorApplicationSearchController.php
··· 7 7 private $navigation; 8 8 private $queryKey; 9 9 private $preface; 10 + private $useOffsetPaging; 11 + 12 + public function setUseOffsetPaging($use_offset_paging) { 13 + $this->useOffsetPaging = $use_offset_paging; 14 + return $this; 15 + } 16 + 17 + public function getUseOffsetPaging() { 18 + return $this->useOffsetPaging; 19 + } 10 20 11 21 public function setPreface($preface) { 12 22 $this->preface = $preface; ··· 213 223 214 224 $query = $engine->buildQueryFromSavedQuery($saved_query); 215 225 216 - $pager = new AphrontCursorPagerView(); 226 + $use_offset_paging = $this->getUseOffsetPaging(); 227 + if ($use_offset_paging) { 228 + $pager = new AphrontPagerView(); 229 + } else { 230 + $pager = new AphrontCursorPagerView(); 231 + } 217 232 $pager->readFromRequest($request); 218 233 $page_size = $engine->getPageSize($saved_query); 219 234 if (is_finite($page_size)) { ··· 225 240 // with INF seems to vary across PHP versions, systems, and runtimes. 226 241 $pager->setPageSize(0xFFFF); 227 242 } 228 - $objects = $query->setViewer($request->getUser()) 229 - ->executeWithCursorPager($pager); 243 + 244 + $query->setViewer($request->getUser()); 245 + 246 + if ($use_offset_paging) { 247 + $objects = $query->executeWithOffsetPager($pager); 248 + } else { 249 + $objects = $query->executeWithCursorPager($pager); 250 + } 230 251 231 252 $list = $parent->renderResultsList($objects, $saved_query); 232 253
+1 -1
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 349 349 * This provides flexibility when constructing URIs, especially from external 350 350 * sources. 351 351 * 352 - * @param AphrontRequest Request to read PHIDs from. 352 + * @param AphrontRequest Request to read strings from. 353 353 * @param string Key to read in the request. 354 354 * @return list<string> List of values. 355 355 */
+2 -9
src/applications/search/index/PhabricatorSearchIndexer.php
··· 11 11 } 12 12 13 13 public function indexDocumentByPHID($phid) { 14 - $doc_indexer_symbols = id(new PhutilSymbolLoader()) 14 + $indexers = id(new PhutilSymbolLoader()) 15 15 ->setAncestorClass('PhabricatorSearchDocumentIndexer') 16 - ->setConcreteOnly(true) 17 - ->setType('class') 18 - ->selectAndLoadSymbols(); 19 - 20 - $indexers = array(); 21 - foreach ($doc_indexer_symbols as $symbol) { 22 - $indexers[] = newv($symbol['name'], array()); 23 - } 16 + ->loadObjects(); 24 17 25 18 foreach ($indexers as $indexer) { 26 19 if ($indexer->shouldIndexDocumentByPHID($phid)) {
+11
src/view/control/AphrontPagerView.php
··· 47 47 return $this; 48 48 } 49 49 50 + final public function readFromRequest(AphrontRequest $request) { 51 + $this->uri = $request->getRequestURI(); 52 + $this->pagingParameter = 'offset'; 53 + $this->offset = $request->getInt($this->pagingParameter); 54 + return $this; 55 + } 56 + 57 + final public function willShowPagingControls() { 58 + return $this->hasMorePages; 59 + } 60 + 50 61 final public function setSurroundingPages($pages) { 51 62 $this->surroundingPages = max(0, $pages); 52 63 return $this;