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

Modernize Differential paging/ordering

Summary: Ref T7803. Move Differential off getPagingColumn() / getReversePaging().

Test Plan: Paged Differential results.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7803

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

+34 -63
+34 -63
src/applications/differential/query/DifferentialRevisionQuery.php
··· 41 41 private $updatedEpochMin; 42 42 private $updatedEpochMax; 43 43 44 - private $order = 'order-modified'; 45 44 const ORDER_MODIFIED = 'order-modified'; 46 45 const ORDER_CREATED = 'order-created'; 47 46 ··· 261 260 * @task config 262 261 */ 263 262 public function setOrder($order_constant) { 264 - $this->order = $order_constant; 263 + switch ($order_constant) { 264 + case self::ORDER_CREATED: 265 + $this->setOrderVector(array('id')); 266 + break; 267 + case self::ORDER_MODIFIED: 268 + $this->setOrderVector(array('updated', 'id')); 269 + break; 270 + default: 271 + throw new Exception(pht('Unknown order "%s".', $order_constant)); 272 + } 273 + 265 274 return $this; 266 275 } 267 276 ··· 853 862 } 854 863 } 855 864 856 - protected function buildPagingClause(AphrontDatabaseConnection $conn_r) { 857 - $default = parent::buildPagingClause($conn_r); 858 - 859 - $before_id = $this->getBeforeID(); 860 - $after_id = $this->getAfterID(); 861 - 862 - if (!$before_id && !$after_id) { 863 - return $default; 864 - } 865 - 866 - if ($before_id) { 867 - $cursor = $this->loadCursorObject($before_id); 868 - } else { 869 - $cursor = $this->loadCursorObject($after_id); 870 - } 871 - 872 - if (!$cursor) { 873 - return null; 874 - } 875 - 876 - $columns = array(); 865 + protected function getDefaultOrderVector() { 866 + return array('updated', 'id'); 867 + } 877 868 878 - switch ($this->order) { 879 - case self::ORDER_CREATED: 880 - return $default; 881 - case self::ORDER_MODIFIED: 882 - $columns[] = array( 883 - 'table' => 'r', 884 - 'column' => 'dateModified', 885 - 'value' => $cursor->getDateModified(), 886 - 'type' => 'int', 887 - ); 888 - break; 889 - } 869 + public function getOrderableColumns() { 870 + $primary = ($this->buildingGlobalOrder ? null : 'r'); 890 871 891 - $columns[] = array( 892 - 'table' => 'r', 893 - 'column' => 'id', 894 - 'value' => $cursor->getID(), 895 - 'type' => 'int', 872 + return array( 873 + 'id' => array( 874 + 'table' => $primary, 875 + 'column' => 'id', 876 + 'type' => 'int', 877 + 'unique' => true, 878 + ), 879 + 'updated' => array( 880 + 'table' => $primary, 881 + 'column' => 'dateModified', 882 + 'type' => 'int', 883 + ), 896 884 ); 897 - 898 - return $this->buildPagingClauseFromMultipleColumns( 899 - $conn_r, 900 - $columns, 901 - array( 902 - 'reversed' => (bool)($before_id xor $this->getReversePaging()), 903 - )); 904 885 } 905 886 906 - protected function getPagingColumn() { 907 - $is_global = $this->buildingGlobalOrder; 908 - switch ($this->order) { 909 - case self::ORDER_MODIFIED: 910 - if ($is_global) { 911 - return 'dateModified'; 912 - } 913 - return 'r.dateModified'; 914 - case self::ORDER_CREATED: 915 - if ($is_global) { 916 - return 'id'; 917 - } 918 - return 'r.id'; 919 - default: 920 - throw new Exception("Unknown query order constant '{$this->order}'."); 921 - } 887 + protected function getPagingValueMap($cursor, array $keys) { 888 + $revision = $this->loadCursorObject($cursor); 889 + return array( 890 + 'id' => $revision->getID(), 891 + 'updated' => $revision->getDateModified(), 892 + ); 922 893 } 923 894 924 895 private function loadRelationships($conn_r, array $revisions) {