mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-19 03:01:11 +01:00
Remove getPagingColumn() / getReversePaging()
Summary: Ref T7803. Remove these in favor of more generalized paging and ordering. Test Plan: Sorted and paged results in various applications. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7803 Differential Revision: https://secure.phabricator.com/D12378
This commit is contained in:
parent
bdd1edea7a
commit
2794c69db5
9 changed files with 8 additions and 83 deletions
|
@ -559,7 +559,6 @@ abstract class PhabricatorController extends AphrontController {
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withObjectPHIDs(array($object->getPHID()))
|
->withObjectPHIDs(array($object->getPHID()))
|
||||||
->needComments(true)
|
->needComments(true)
|
||||||
->setReversePaging(false)
|
|
||||||
->executeWithCursorPager($pager);
|
->executeWithCursorPager($pager);
|
||||||
$xactions = array_reverse($xactions);
|
$xactions = array_reverse($xactions);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
final class PhabricatorConfigHistoryController
|
final class PhabricatorConfigHistoryController
|
||||||
extends PhabricatorConfigController {
|
extends PhabricatorConfigController {
|
||||||
|
|
||||||
|
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
@ -11,7 +10,6 @@ final class PhabricatorConfigHistoryController
|
||||||
$xactions = id(new PhabricatorConfigTransactionQuery())
|
$xactions = id(new PhabricatorConfigTransactionQuery())
|
||||||
->setViewer($user)
|
->setViewer($user)
|
||||||
->needComments(true)
|
->needComments(true)
|
||||||
->setReversePaging(false)
|
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$object = new PhabricatorConfigEntry();
|
$object = new PhabricatorConfigEntry();
|
||||||
|
|
|
@ -7,8 +7,9 @@ final class ConpherenceTransactionQuery
|
||||||
return new ConpherenceTransaction();
|
return new ConpherenceTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getReversePaging() {
|
protected function getDefaultOrderVector() {
|
||||||
return false;
|
// TODO: Can we get rid of this?
|
||||||
|
return array('-id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,9 @@ final class DifferentialHunkQuery
|
||||||
return 'PhabricatorDifferentialApplication';
|
return 'PhabricatorDifferentialApplication';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getReversePaging() {
|
protected function getDefaultOrderVector() {
|
||||||
return true;
|
// TODO: Do we need this?
|
||||||
|
return array('-id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,10 +118,6 @@ final class PonderAnswerQuery
|
||||||
return $answers;
|
return $answers;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getReversePaging() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
return 'PhabricatorPonderApplication';
|
return 'PhabricatorPonderApplication';
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,7 @@ final class PonderQuestionQuery
|
||||||
if ($this->needAnswers) {
|
if ($this->needAnswers) {
|
||||||
$aquery = id(new PonderAnswerQuery())
|
$aquery = id(new PonderAnswerQuery())
|
||||||
->setViewer($this->getViewer())
|
->setViewer($this->getViewer())
|
||||||
|
->setOrderVector(array('-id'))
|
||||||
->withQuestionIDs(mpull($questions, 'getID'));
|
->withQuestionIDs(mpull($questions, 'getID'));
|
||||||
|
|
||||||
if ($this->needViewerVotes) {
|
if ($this->needViewerVotes) {
|
||||||
|
|
|
@ -312,7 +312,7 @@ final class PhabricatorRepositoryQuery
|
||||||
return $repositories;
|
return $repositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrimaryTableAlias() {
|
protected function getPrimaryTableAlias() {
|
||||||
return 'r';
|
return 'r';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ abstract class PhabricatorApplicationTransactionQuery
|
||||||
private $objectPHIDs;
|
private $objectPHIDs;
|
||||||
private $authorPHIDs;
|
private $authorPHIDs;
|
||||||
private $transactionTypes;
|
private $transactionTypes;
|
||||||
private $reversePaging = true;
|
|
||||||
|
|
||||||
private $needComments = true;
|
private $needComments = true;
|
||||||
private $needHandles = true;
|
private $needHandles = true;
|
||||||
|
@ -18,15 +17,6 @@ abstract class PhabricatorApplicationTransactionQuery
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setReversePaging($bool) {
|
|
||||||
$this->reversePaging = $bool;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getReversePaging() {
|
|
||||||
return $this->reversePaging;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function withPHIDs(array $phids) {
|
public function withPHIDs(array $phids) {
|
||||||
$this->phids = $phids;
|
$this->phids = $phids;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -18,10 +18,6 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
private $internalPaging;
|
private $internalPaging;
|
||||||
private $orderVector;
|
private $orderVector;
|
||||||
|
|
||||||
protected function getPagingColumn() {
|
|
||||||
return 'id';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getPagingValue($result) {
|
protected function getPagingValue($result) {
|
||||||
if (!is_object($result)) {
|
if (!is_object($result)) {
|
||||||
// This interface can't be typehinted and PHP gets really angry if we
|
// This interface can't be typehinted and PHP gets really angry if we
|
||||||
|
@ -31,10 +27,6 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
return $result->getID();
|
return $result->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getReversePaging() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function nextPage(array $page) {
|
protected function nextPage(array $page) {
|
||||||
// See getPagingViewer() for a description of this flag.
|
// See getPagingViewer() for a description of this flag.
|
||||||
$this->internalPaging = true;
|
$this->internalPaging = true;
|
||||||
|
@ -171,28 +163,6 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
|
|
||||||
protected function buildPagingClause(AphrontDatabaseConnection $conn) {
|
protected function buildPagingClause(AphrontDatabaseConnection $conn) {
|
||||||
$orderable = $this->getOrderableColumns();
|
$orderable = $this->getOrderableColumns();
|
||||||
|
|
||||||
// TODO: Remove this once subqueries modernize.
|
|
||||||
if (!$orderable) {
|
|
||||||
if ($this->beforeID) {
|
|
||||||
return qsprintf(
|
|
||||||
$conn,
|
|
||||||
'%Q %Q %s',
|
|
||||||
$this->getPagingColumn(),
|
|
||||||
$this->getReversePaging() ? '<' : '>',
|
|
||||||
$this->beforeID);
|
|
||||||
} else if ($this->afterID) {
|
|
||||||
return qsprintf(
|
|
||||||
$conn,
|
|
||||||
'%Q %Q %s',
|
|
||||||
$this->getPagingColumn(),
|
|
||||||
$this->getReversePaging() ? '>' : '<',
|
|
||||||
$this->afterID);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$vector = $this->getOrderVector();
|
$vector = $this->getOrderVector();
|
||||||
|
|
||||||
if ($this->beforeID !== null) {
|
if ($this->beforeID !== null) {
|
||||||
|
@ -543,13 +513,6 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
* @task order
|
* @task order
|
||||||
*/
|
*/
|
||||||
public function getOrderableColumns() {
|
public function getOrderableColumns() {
|
||||||
// TODO: Remove this once all subclasses move off the old stuff.
|
|
||||||
if ($this->getPagingColumn() !== 'id') {
|
|
||||||
// This class has bad old custom logic around paging, so return nothing
|
|
||||||
// here. This deactivates the new order code.
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$columns = array(
|
$columns = array(
|
||||||
'id' => array(
|
'id' => array(
|
||||||
'table' => $this->getPrimaryTableAlias(),
|
'table' => $this->getPrimaryTableAlias(),
|
||||||
|
@ -593,26 +556,6 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
*/
|
*/
|
||||||
final protected function buildOrderClause(AphrontDatabaseConnection $conn) {
|
final protected function buildOrderClause(AphrontDatabaseConnection $conn) {
|
||||||
$orderable = $this->getOrderableColumns();
|
$orderable = $this->getOrderableColumns();
|
||||||
|
|
||||||
// TODO: Remove this once all subclasses move off the old stuff. We'll
|
|
||||||
// only enter this block for code using older ordering mechanisms. New
|
|
||||||
// code should expose an orderable column list.
|
|
||||||
if (!$orderable) {
|
|
||||||
if ($this->beforeID) {
|
|
||||||
return qsprintf(
|
|
||||||
$conn,
|
|
||||||
'ORDER BY %Q %Q',
|
|
||||||
$this->getPagingColumn(),
|
|
||||||
$this->getReversePaging() ? 'DESC' : 'ASC');
|
|
||||||
} else {
|
|
||||||
return qsprintf(
|
|
||||||
$conn,
|
|
||||||
'ORDER BY %Q %Q',
|
|
||||||
$this->getPagingColumn(),
|
|
||||||
$this->getReversePaging() ? 'ASC' : 'DESC');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$vector = $this->getOrderVector();
|
$vector = $this->getOrderVector();
|
||||||
|
|
||||||
$parts = array();
|
$parts = array();
|
||||||
|
@ -636,10 +579,6 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
array $parts) {
|
array $parts) {
|
||||||
|
|
||||||
$is_query_reversed = false;
|
$is_query_reversed = false;
|
||||||
if ($this->getReversePaging()) {
|
|
||||||
$is_query_reversed = !$is_query_reversed;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->getBeforeID()) {
|
if ($this->getBeforeID()) {
|
||||||
$is_query_reversed = !$is_query_reversed;
|
$is_query_reversed = !$is_query_reversed;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue