Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13955087
D12358.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D12358.id.diff
View Options
diff --git a/src/applications/differential/query/DifferentialRevisionQuery.php b/src/applications/differential/query/DifferentialRevisionQuery.php
--- a/src/applications/differential/query/DifferentialRevisionQuery.php
+++ b/src/applications/differential/query/DifferentialRevisionQuery.php
@@ -861,14 +861,6 @@
}
}
- private function loadCursorObject($id) {
- $results = id(new DifferentialRevisionQuery())
- ->setViewer($this->getPagingViewer())
- ->withIDs(array((int)$id))
- ->execute();
- return head($results);
- }
-
protected function buildPagingClause(AphrontDatabaseConnection $conn_r) {
$default = parent::buildPagingClause($conn_r);
diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php
--- a/src/applications/maniphest/query/ManiphestTaskQuery.php
+++ b/src/applications/maniphest/query/ManiphestTaskQuery.php
@@ -949,14 +949,6 @@
return array_mergev($phids);
}
- private function loadCursorObject($id) {
- $results = id(new ManiphestTaskQuery())
- ->setViewer($this->getPagingViewer())
- ->withIDs(array((int)$id))
- ->execute();
- return head($results);
- }
-
protected function getPagingValue($result) {
$id = $result->getID();
diff --git a/src/applications/releeph/query/ReleephProductQuery.php b/src/applications/releeph/query/ReleephProductQuery.php
--- a/src/applications/releeph/query/ReleephProductQuery.php
+++ b/src/applications/releeph/query/ReleephProductQuery.php
@@ -10,7 +10,6 @@
private $needArcanistProjects;
- private $order = 'order-id';
const ORDER_ID = 'order-id';
const ORDER_NAME = 'order-name';
@@ -20,7 +19,16 @@
}
public function setOrder($order) {
- $this->order = $order;
+ switch ($order) {
+ case self::ORDER_ID:
+ $this->setOrderVector(array('id'));
+ break;
+ case self::ORDER_NAME:
+ $this->setOrderVector(array('name'));
+ break;
+ default:
+ throw new Exception(pht('Order "%s" not supported.', $order));
+ }
return $this;
}
@@ -139,31 +147,24 @@
return $this->formatWhereClause($where);
}
- protected function getReversePaging() {
- switch ($this->order) {
- case self::ORDER_NAME:
- return true;
- }
- return parent::getReversePaging();
+ public function getOrderableColumns() {
+ return parent::getOrderableColumns() + array(
+ 'name' => array(
+ 'column' => 'name',
+ 'unique' => true,
+ 'reverse' => true,
+ 'type' => 'string',
+ ),
+ );
}
- protected function getPagingValue($result) {
- switch ($this->order) {
- case self::ORDER_NAME:
- return $result->getName();
- }
- return parent::getPagingValue();
- }
+ protected function getPagingValueMap($cursor, array $keys) {
+ $product = $this->loadCursorObject($cursor);
- protected function getPagingColumn() {
- switch ($this->order) {
- case self::ORDER_NAME:
- return 'name';
- case self::ORDER_ID:
- return parent::getPagingColumn();
- default:
- throw new Exception("Uknown order '{$this->order}'!");
- }
+ return array(
+ 'id' => $product->getID(),
+ 'name' => $product->getName(),
+ );
}
public function getQueryApplicationClass() {
diff --git a/src/applications/repository/query/PhabricatorRepositoryQuery.php b/src/applications/repository/query/PhabricatorRepositoryQuery.php
--- a/src/applications/repository/query/PhabricatorRepositoryQuery.php
+++ b/src/applications/repository/query/PhabricatorRepositoryQuery.php
@@ -340,7 +340,7 @@
return $this->formatOrderClause($conn, $parts);
}
- private function loadCursorObject($id) {
+ protected function loadCursorObject($id) {
$query = id(new PhabricatorRepositoryQuery())
->setViewer($this->getPagingViewer())
->withIDs(array((int)$id));
diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
--- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
+++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
@@ -244,6 +244,22 @@
);
}
+ protected function loadCursorObject($cursor) {
+ $query = newv(get_class($this), array())
+ ->setViewer($this->getPagingViewer())
+ ->withIDs(array((int)$cursor));
+
+ $object = $query->executeOne();
+ if (!$object) {
+ throw new Exception(
+ pht(
+ 'Cursor "%s" does not identify a valid object.',
+ $cursor));
+ }
+
+ return $object;
+ }
+
/**
* Simplifies the task of constructing a paging clause across multiple
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 15 2024, 12:09 AM (5 w, 12 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6709465
Default Alt Text
D12358.id.diff (4 KB)
Attached To
Mode
D12358: Modernize ReleephProjectQuery ordering/paging
Attached
Detach File
Event Timeline
Log In to Comment