Page MenuHomePhabricator

D9008.diff
No OneTemporary

D9008.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4377,11 +4377,7 @@
'PhabricatorFeedController' => 'PhabricatorController',
'PhabricatorFeedDAO' => 'PhabricatorLiskDAO',
'PhabricatorFeedDetailController' => 'PhabricatorFeedController',
- 'PhabricatorFeedListController' =>
- array(
- 0 => 'PhabricatorFeedController',
- 1 => 'PhabricatorApplicationSearchResultsControllerInterface',
- ),
+ 'PhabricatorFeedListController' => 'PhabricatorFeedController',
'PhabricatorFeedManagementRepublishWorkflow' => 'PhabricatorFeedManagementWorkflow',
'PhabricatorFeedManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorFeedPublicStreamController' => 'PhabricatorFeedController',
diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php
@@ -66,17 +66,10 @@
}
$query = $engine->buildQueryFromSavedQuery($saved);
+ $pager = $engine->newPagerForSavedQuery($saved);
+ $results = $engine->executeQuery($query, $pager);
- $results = $query
- ->setViewer($viewer)
- ->execute();
-
- $out = array();
- foreach ($results as $result) {
- $out[] = phutil_tag('div', array(), $result->getPHID());
- }
-
- return $out;
+ return $engine->renderResults($results, $saved);
}
}
diff --git a/src/applications/feed/controller/PhabricatorFeedListController.php b/src/applications/feed/controller/PhabricatorFeedListController.php
--- a/src/applications/feed/controller/PhabricatorFeedListController.php
+++ b/src/applications/feed/controller/PhabricatorFeedListController.php
@@ -1,7 +1,6 @@
<?php
-final class PhabricatorFeedListController extends PhabricatorFeedController
- implements PhabricatorApplicationSearchResultsControllerInterface {
+final class PhabricatorFeedListController extends PhabricatorFeedController {
private $queryKey;
@@ -23,16 +22,4 @@
return $this->delegateToController($controller);
}
- public function renderResultsList(
- array $feed,
- PhabricatorSavedQuery $query) {
-
- $builder = new PhabricatorFeedBuilder($feed);
- $builder->setShowHovercards(true);
- $builder->setUser($this->getRequest()->getUser());
- $view = $builder->buildView();
-
- return phutil_tag_div('phabricator-feed-frame', $view);
- }
-
}
diff --git a/src/applications/feed/query/PhabricatorFeedSearchEngine.php b/src/applications/feed/query/PhabricatorFeedSearchEngine.php
--- a/src/applications/feed/query/PhabricatorFeedSearchEngine.php
+++ b/src/applications/feed/query/PhabricatorFeedSearchEngine.php
@@ -124,4 +124,16 @@
return parent::buildSavedQueryFromBuiltin($query_key);
}
+ public function renderResults(
+ array $objects,
+ PhabricatorSavedQuery $query) {
+
+ $builder = new PhabricatorFeedBuilder($objects);
+ $builder->setShowHovercards(true);
+ $builder->setUser($this->requireViewer());
+ $view = $builder->buildView();
+
+ return phutil_tag_div('phabricator-feed-frame', $view);
+ }
+
}
diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php
--- a/src/applications/search/controller/PhabricatorApplicationSearchController.php
+++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php
@@ -7,16 +7,6 @@
private $navigation;
private $queryKey;
private $preface;
- private $useOffsetPaging;
-
- public function setUseOffsetPaging($use_offset_paging) {
- $this->useOffsetPaging = $use_offset_paging;
- return $this;
- }
-
- public function getUseOffsetPaging() {
- return $this->useOffsetPaging;
- }
public function setPreface($preface) {
$this->preface = $preface;
@@ -78,11 +68,6 @@
$engine->setViewer($this->getRequest()->getUser());
$parent = $this->getDelegatingController();
- $interface = 'PhabricatorApplicationSearchResultsControllerInterface';
- if (!$parent instanceof $interface) {
- throw new Exception(
- "Delegating controller must implement '{$interface}'.");
- }
}
public function processRequest() {
@@ -223,34 +208,23 @@
$query = $engine->buildQueryFromSavedQuery($saved_query);
- $use_offset_paging = $this->getUseOffsetPaging();
- if ($use_offset_paging) {
- $pager = new AphrontPagerView();
- } else {
- $pager = new AphrontCursorPagerView();
- }
+ $pager = $engine->newPagerForSavedQuery($saved_query);
$pager->readFromRequest($request);
- $page_size = $engine->getPageSize($saved_query);
- if (is_finite($page_size)) {
- $pager->setPageSize($page_size);
- } else {
- // Consider an INF pagesize to mean a large finite pagesize.
- // TODO: It would be nice to handle this more gracefully, but math
- // with INF seems to vary across PHP versions, systems, and runtimes.
- $pager->setPageSize(0xFFFF);
- }
+ $objects = $engine->executeQuery($query, $pager);
- $query->setViewer($request->getUser());
+ // TODO: To support Dashboard panels, rendering is moving into
+ // SearchEngines. Move it all the way in and then get rid of this.
- if ($use_offset_paging) {
- $objects = $query->executeWithOffsetPager($pager);
+ $interface = 'PhabricatorApplicationSearchResultsControllerInterface';
+ if ($parent instanceof $interface) {
+ $list = $parent->renderResultsList($objects, $saved_query);
} else {
- $objects = $query->executeWithCursorPager($pager);
+ $list = $engine->renderResults(
+ $objects,
+ $saved_query);
}
- $list = $parent->renderResultsList($objects, $saved_query);
-
$nav->appendChild($list);
// TODO: This is a bit hacky.
diff --git a/src/applications/search/controller/PhabricatorSearchController.php b/src/applications/search/controller/PhabricatorSearchController.php
--- a/src/applications/search/controller/PhabricatorSearchController.php
+++ b/src/applications/search/controller/PhabricatorSearchController.php
@@ -76,7 +76,6 @@
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine($engine)
- ->setUseOffsetPaging(true)
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
--- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
+++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
@@ -9,6 +9,8 @@
* @task uri Query URIs
* @task dates Date Filters
* @task read Reading Utilities
+ * @task exec Paging and Executing Queries
+ * @task render Rendering Results
*
* @group search
*/
@@ -502,7 +504,7 @@
}
-/* -( Pagination )--------------------------------------------------------- */
+/* -( Paging and Executing Queries )--------------------------------------- */
public function getPageSize(PhabricatorSavedQuery $saved) {
@@ -510,6 +512,59 @@
}
+ public function shouldUseOffsetPaging() {
+ return false;
+ }
+
+
+ public function newPagerForSavedQuery(PhabricatorSavedQuery $saved) {
+ if ($this->shouldUseOffsetPaging()) {
+ $pager = new AphrontPagerView();
+ } else {
+ $pager = new AphrontCursorPagerView();
+ }
+
+ $page_size = $this->getPageSize($saved);
+ if (is_finite($page_size)) {
+ $pager->setPageSize($page_size);
+ } else {
+ // Consider an INF pagesize to mean a large finite pagesize.
+
+ // TODO: It would be nice to handle this more gracefully, but math
+ // with INF seems to vary across PHP versions, systems, and runtimes.
+ $pager->setPageSize(0xFFFF);
+ }
+
+ return $pager;
+ }
+
+
+ public function executeQuery(
+ PhabricatorPolicyAwareQuery $query,
+ AphrontView $pager) {
+
+ $query->setViewer($this->requireViewer());
+
+ if ($this->shouldUseOffsetPaging()) {
+ $objects = $query->executeWithOffsetPager($pager);
+ } else {
+ $objects = $query->executeWithCursorPager($pager);
+ }
+
+ return $objects;
+ }
+
+
+/* -( Rendering )---------------------------------------------------------- */
+
+
+ public function renderResults(
+ array $objects,
+ PhabricatorSavedQuery $query) {
+ throw new Exception(pht('Not supported here yet!'));
+ }
+
+
/* -( Application Search )------------------------------------------------- */
diff --git a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
--- a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
+++ b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
@@ -229,5 +229,9 @@
return $results;
}
+ public function shouldUseOffsetPaging() {
+ return true;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 18, 5:08 PM (4 h, 59 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6999825
Default Alt Text
D9008.diff (9 KB)

Event Timeline