Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14097895
D17667.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D17667.diff
View Options
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
@@ -9148,7 +9148,7 @@
'PhabricatorSearchDocument' => 'PhabricatorSearchDAO',
'PhabricatorSearchDocumentField' => 'PhabricatorSearchDAO',
'PhabricatorSearchDocumentFieldType' => 'Phobject',
- 'PhabricatorSearchDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhabricatorSearchDocumentQuery' => 'PhabricatorPolicyAwareQuery',
'PhabricatorSearchDocumentRelationship' => 'PhabricatorSearchDAO',
'PhabricatorSearchDocumentTypeDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorSearchEditController' => 'PhabricatorSearchBaseController',
diff --git a/src/applications/search/query/PhabricatorSearchDocumentQuery.php b/src/applications/search/query/PhabricatorSearchDocumentQuery.php
--- a/src/applications/search/query/PhabricatorSearchDocumentQuery.php
+++ b/src/applications/search/query/PhabricatorSearchDocumentQuery.php
@@ -1,10 +1,11 @@
<?php
final class PhabricatorSearchDocumentQuery
- extends PhabricatorCursorPagedPolicyAwareQuery {
+ extends PhabricatorPolicyAwareQuery {
private $savedQuery;
private $objectCapabilities;
+ private $unfilteredOffset;
public function withSavedQuery(PhabricatorSavedQuery $query) {
$this->savedQuery = $query;
@@ -20,11 +21,27 @@
if ($this->objectCapabilities) {
return $this->objectCapabilities;
}
+
return $this->getRequiredCapabilities();
}
+ protected function willExecute() {
+ $this->unfilteredOffset = 0;
+ }
+
protected function loadPage() {
- $phids = $this->loadDocumentPHIDsWithoutPolicyChecks();
+ // NOTE: The offset and limit information in the inherited properties of
+ // this object represent a policy-filtered offset and limit, but the
+ // underlying query engine needs an unfiltered offset and limit. We keep
+ // track of an unfiltered result offset internally.
+
+ $query = id(clone($this->savedQuery))
+ ->setParameter('offset', $this->unfilteredOffset)
+ ->setParameter('limit', $this->getRawResultLimit());
+
+ $phids = PhabricatorSearchService::executeSearch($query);
+
+ $this->unfilteredOffset += count($phids);
$handles = id(new PhabricatorHandleQuery())
->setViewer($this->getViewer())
@@ -69,25 +86,13 @@
return $handles;
}
- public function loadDocumentPHIDsWithoutPolicyChecks() {
- $query = id(clone($this->savedQuery))
- ->setParameter('offset', $this->getOffset())
- ->setParameter('limit', $this->getRawResultLimit());
- return PhabricatorSearchService::executeSearch($query);
- }
-
public function getQueryApplicationClass() {
return 'PhabricatorSearchApplication';
}
- protected function getResultCursor($result) {
- throw new Exception(
- pht(
- 'This query does not support cursor paging; it must be offset paged.'));
- }
-
protected function nextPage(array $page) {
- $this->setOffset($this->getOffset() + count($page));
+ // We already updated the internal offset in `loadPage()` after loading
+ // results, so we do not need to make any additional state updates here.
return $this;
}
diff --git a/src/view/phui/PHUIPagerView.php b/src/view/phui/PHUIPagerView.php
--- a/src/view/phui/PHUIPagerView.php
+++ b/src/view/phui/PHUIPagerView.php
@@ -55,7 +55,7 @@
}
public function willShowPagingControls() {
- return $this->hasMorePages;
+ return $this->hasMorePages || $this->getOffset();
}
public function getHasMorePages() {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 7:57 AM (14 h, 12 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6792807
Default Alt Text
D17667.diff (3 KB)
Attached To
Mode
D17667: Fix pagination of fulltext search results
Attached
Detach File
Event Timeline
Log In to Comment