From d4847c3eeb787a80c67f297720d79a2b7281bb8e Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 18 Mar 2019 11:44:54 -0700 Subject: [PATCH] Convert simple query subclasses to use internal cursors Summary: Depends on D20291. Ref T13259. Move all the simple cases (where paging depends only on the partial object and does not depend on keys) to a simple wrapper. This leaves a smaller set of more complex cases where we care about external data or which keys were requested that I'll convert in followups. Test Plan: Poked at things, but a lot of stuff is still broken until everything is converted. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13259 Differential Revision: https://secure.phabricator.com/D20292 --- .../almanac/query/AlmanacDeviceQuery.php | 7 +++---- .../almanac/query/AlmanacNamespaceQuery.php | 7 +++---- .../almanac/query/AlmanacServiceQuery.php | 7 +++---- .../badges/query/PhabricatorBadgesQuery.php | 8 ++++---- .../calendar/query/PhabricatorCalendarEventQuery.php | 7 +++---- .../countdown/query/PhabricatorCountdownQuery.php | 7 +++---- .../differential/query/DifferentialRevisionQuery.php | 7 +++---- .../diffusion/query/DiffusionCommitQuery.php | 7 +++---- src/applications/diviner/query/DivinerBookQuery.php | 7 +++---- .../query/HarbormasterBuildPlanQuery.php | 7 +++---- .../macro/query/PhabricatorMacroQuery.php | 7 +++---- .../owners/query/PhabricatorOwnersPackageQuery.php | 7 +++---- .../people/query/PhabricatorPeopleQuery.php | 7 +++---- src/applications/phame/query/PhamePostQuery.php | 12 ++++-------- src/applications/phlux/query/PhluxVariableQuery.php | 4 ++-- .../phrequent/query/PhrequentUserTimeQuery.php | 9 ++++----- .../phurl/query/PhabricatorPhurlURLQuery.php | 7 ------- .../project/query/PhabricatorProjectQuery.php | 9 ++++----- .../releeph/query/ReleephProductQuery.php | 8 +++----- .../PhabricatorCursorPagedPolicyAwareQuery.php | 4 ++++ 20 files changed, 61 insertions(+), 84 deletions(-) diff --git a/src/applications/almanac/query/AlmanacDeviceQuery.php b/src/applications/almanac/query/AlmanacDeviceQuery.php index 0d38070e0b..21f8c952ef 100644 --- a/src/applications/almanac/query/AlmanacDeviceQuery.php +++ b/src/applications/almanac/query/AlmanacDeviceQuery.php @@ -122,11 +122,10 @@ final class AlmanacDeviceQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $device = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $device->getID(), - 'name' => $device->getName(), + 'id' => (int)$object->getID(), + 'name' => $object->getName(), ); } diff --git a/src/applications/almanac/query/AlmanacNamespaceQuery.php b/src/applications/almanac/query/AlmanacNamespaceQuery.php index 81332cf03b..d4378e17c7 100644 --- a/src/applications/almanac/query/AlmanacNamespaceQuery.php +++ b/src/applications/almanac/query/AlmanacNamespaceQuery.php @@ -79,11 +79,10 @@ final class AlmanacNamespaceQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $namespace = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $namespace->getID(), - 'name' => $namespace->getName(), + 'id' => (int)$object->getID(), + 'name' => $object->getName(), ); } diff --git a/src/applications/almanac/query/AlmanacServiceQuery.php b/src/applications/almanac/query/AlmanacServiceQuery.php index 3374413e5b..edc55276a9 100644 --- a/src/applications/almanac/query/AlmanacServiceQuery.php +++ b/src/applications/almanac/query/AlmanacServiceQuery.php @@ -206,11 +206,10 @@ final class AlmanacServiceQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $service = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $service->getID(), - 'name' => $service->getName(), + 'id' => (int)$object->getID(), + 'name' => $object->getName(), ); } diff --git a/src/applications/badges/query/PhabricatorBadgesQuery.php b/src/applications/badges/query/PhabricatorBadgesQuery.php index c977e3f826..dcadf881fe 100644 --- a/src/applications/badges/query/PhabricatorBadgesQuery.php +++ b/src/applications/badges/query/PhabricatorBadgesQuery.php @@ -108,11 +108,11 @@ final class PhabricatorBadgesQuery ) + parent::getOrderableColumns(); } - protected function getPagingValueMap($cursor, array $keys) { - $badge = $this->loadCursorObject($cursor); + + protected function newPagingMapFromPartialObject($object) { return array( - 'quality' => $badge->getQuality(), - 'id' => $badge->getID(), + 'id' => (int)$object->getID(), + 'quality' => $object->getQuality(), ); } diff --git a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php index fc1399fdb3..db50bb4d77 100644 --- a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php @@ -140,11 +140,10 @@ final class PhabricatorCalendarEventQuery ) + parent::getOrderableColumns(); } - protected function getPagingValueMap($cursor, array $keys) { - $event = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'start' => $event->getStartDateTimeEpoch(), - 'id' => $event->getID(), + 'id' => (int)$object->getID(), + 'start' => (int)$object->getStartDateTimeEpoch(), ); } diff --git a/src/applications/countdown/query/PhabricatorCountdownQuery.php b/src/applications/countdown/query/PhabricatorCountdownQuery.php index e6c410ee49..67a2f3a9e3 100644 --- a/src/applications/countdown/query/PhabricatorCountdownQuery.php +++ b/src/applications/countdown/query/PhabricatorCountdownQuery.php @@ -97,11 +97,10 @@ final class PhabricatorCountdownQuery ) + parent::getOrderableColumns(); } - protected function getPagingValueMap($cursor, array $keys) { - $countdown = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'epoch' => $countdown->getEpoch(), - 'id' => $countdown->getID(), + 'id' => (int)$object->getID(), + 'epoch' => (int)$object->getEpoch(), ); } diff --git a/src/applications/differential/query/DifferentialRevisionQuery.php b/src/applications/differential/query/DifferentialRevisionQuery.php index fdd4904bee..a385fc5252 100644 --- a/src/applications/differential/query/DifferentialRevisionQuery.php +++ b/src/applications/differential/query/DifferentialRevisionQuery.php @@ -800,11 +800,10 @@ final class DifferentialRevisionQuery ) + parent::getOrderableColumns(); } - protected function getPagingValueMap($cursor, array $keys) { - $revision = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $revision->getID(), - 'updated' => $revision->getDateModified(), + 'id' => (int)$object->getID(), + 'updated' => (int)$object->getDateModified(), ); } diff --git a/src/applications/diffusion/query/DiffusionCommitQuery.php b/src/applications/diffusion/query/DiffusionCommitQuery.php index 03eb0b9edf..bc555a4fb4 100644 --- a/src/applications/diffusion/query/DiffusionCommitQuery.php +++ b/src/applications/diffusion/query/DiffusionCommitQuery.php @@ -924,11 +924,10 @@ final class DiffusionCommitQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $commit = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $commit->getID(), - 'epoch' => $commit->getEpoch(), + 'id' => (int)$object->getID(), + 'epoch' => (int)$object->getEpoch(), ); } diff --git a/src/applications/diviner/query/DivinerBookQuery.php b/src/applications/diviner/query/DivinerBookQuery.php index d540d971b0..2d6527ec96 100644 --- a/src/applications/diviner/query/DivinerBookQuery.php +++ b/src/applications/diviner/query/DivinerBookQuery.php @@ -181,11 +181,10 @@ final class DivinerBookQuery extends PhabricatorCursorPagedPolicyAwareQuery { ); } - protected function getPagingValueMap($cursor, array $keys) { - $book = $this->loadCursorObject($cursor); - + protected function newPagingMapFromPartialObject($object) { return array( - 'name' => $book->getName(), + 'id' => (int)$object->getID(), + 'name' => $object->getName(), ); } diff --git a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php index 4058325140..c903fbb37f 100644 --- a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php +++ b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php @@ -133,11 +133,10 @@ final class HarbormasterBuildPlanQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $plan = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $plan->getID(), - 'name' => $plan->getName(), + 'id' => (int)$object->getID(), + 'name' => $object->getName(), ); } diff --git a/src/applications/macro/query/PhabricatorMacroQuery.php b/src/applications/macro/query/PhabricatorMacroQuery.php index 3ba30502d5..7635b68b73 100644 --- a/src/applications/macro/query/PhabricatorMacroQuery.php +++ b/src/applications/macro/query/PhabricatorMacroQuery.php @@ -249,11 +249,10 @@ final class PhabricatorMacroQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $macro = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $macro->getID(), - 'name' => $macro->getName(), + 'id' => (int)$object->getID(), + 'name' => $object->getName(), ); } diff --git a/src/applications/owners/query/PhabricatorOwnersPackageQuery.php b/src/applications/owners/query/PhabricatorOwnersPackageQuery.php index 6d6ccb2ed2..67b4836a5a 100644 --- a/src/applications/owners/query/PhabricatorOwnersPackageQuery.php +++ b/src/applications/owners/query/PhabricatorOwnersPackageQuery.php @@ -267,11 +267,10 @@ final class PhabricatorOwnersPackageQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $package = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $package->getID(), - 'name' => $package->getName(), + 'id' => (int)$object->getID(), + 'name' => $object->getName(), ); } diff --git a/src/applications/people/query/PhabricatorPeopleQuery.php b/src/applications/people/query/PhabricatorPeopleQuery.php index 542b685e29..5e737aaf90 100644 --- a/src/applications/people/query/PhabricatorPeopleQuery.php +++ b/src/applications/people/query/PhabricatorPeopleQuery.php @@ -379,11 +379,10 @@ final class PhabricatorPeopleQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $user = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $user->getID(), - 'username' => $user->getUsername(), + 'id' => (int)$object->getID(), + 'username' => $object->getUsername(), ); } diff --git a/src/applications/phame/query/PhamePostQuery.php b/src/applications/phame/query/PhamePostQuery.php index 85ef470cea..d7396e553f 100644 --- a/src/applications/phame/query/PhamePostQuery.php +++ b/src/applications/phame/query/PhamePostQuery.php @@ -171,15 +171,11 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery { ); } - protected function getPagingValueMap($cursor, array $keys) { - $post = $this->loadCursorObject($cursor); - - $map = array( - 'datePublished' => $post->getDatePublished(), - 'id' => $post->getID(), + protected function newPagingMapFromPartialObject($object) { + return array( + 'id' => (int)$object->getID(), + 'datePublished' => (int)$object->getDatePublished(), ); - - return $map; } public function getQueryApplicationClass() { diff --git a/src/applications/phlux/query/PhluxVariableQuery.php b/src/applications/phlux/query/PhluxVariableQuery.php index 75abd044d0..8ec4bc9334 100644 --- a/src/applications/phlux/query/PhluxVariableQuery.php +++ b/src/applications/phlux/query/PhluxVariableQuery.php @@ -81,9 +81,9 @@ final class PhluxVariableQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $object = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( + 'id' => (int)$object->getID(), 'key' => $object->getVariableKey(), ); } diff --git a/src/applications/phrequent/query/PhrequentUserTimeQuery.php b/src/applications/phrequent/query/PhrequentUserTimeQuery.php index cf5122c020..6400771a00 100644 --- a/src/applications/phrequent/query/PhrequentUserTimeQuery.php +++ b/src/applications/phrequent/query/PhrequentUserTimeQuery.php @@ -133,12 +133,11 @@ final class PhrequentUserTimeQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $usertime = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $usertime->getID(), - 'start' => $usertime->getDateStarted(), - 'end' => $usertime->getDateEnded(), + 'id' => (int)$object->getID(), + 'start' => (int)$object->getDateStarted(), + 'end' => (int)$object->getDateEnded(), ); } diff --git a/src/applications/phurl/query/PhabricatorPhurlURLQuery.php b/src/applications/phurl/query/PhabricatorPhurlURLQuery.php index 74cced0771..6efbbd5b4c 100644 --- a/src/applications/phurl/query/PhabricatorPhurlURLQuery.php +++ b/src/applications/phurl/query/PhabricatorPhurlURLQuery.php @@ -50,13 +50,6 @@ final class PhabricatorPhurlURLQuery return $this; } - protected function getPagingValueMap($cursor, array $keys) { - $url = $this->loadCursorObject($cursor); - return array( - 'id' => $url->getID(), - ); - } - protected function loadPage() { return $this->loadStandardPage($this->newResultObject()); } diff --git a/src/applications/project/query/PhabricatorProjectQuery.php b/src/applications/project/query/PhabricatorProjectQuery.php index f6087f7d2a..b08a58501f 100644 --- a/src/applications/project/query/PhabricatorProjectQuery.php +++ b/src/applications/project/query/PhabricatorProjectQuery.php @@ -201,12 +201,11 @@ final class PhabricatorProjectQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $project = $this->loadCursorObject($cursor); + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $project->getID(), - 'name' => $project->getName(), - 'status' => $project->getStatus(), + 'id' => (int)$object->getID(), + 'name' => $object->getName(), + 'status' => $object->getStatus(), ); } diff --git a/src/applications/releeph/query/ReleephProductQuery.php b/src/applications/releeph/query/ReleephProductQuery.php index c039950379..118b9919a8 100644 --- a/src/applications/releeph/query/ReleephProductQuery.php +++ b/src/applications/releeph/query/ReleephProductQuery.php @@ -130,12 +130,10 @@ final class ReleephProductQuery ); } - protected function getPagingValueMap($cursor, array $keys) { - $product = $this->loadCursorObject($cursor); - + protected function newPagingMapFromPartialObject($object) { return array( - 'id' => $product->getID(), - 'name' => $product->getName(), + 'id' => (int)$object->getID(), + 'name' => $object->getName(), ); } diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php index 1f9cc9c4d0..def502e11f 100644 --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -62,6 +62,10 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery $object = $cursor->getObject(); + return $this->newPagingMapFromPartialObject($object); + } + + protected function newPagingMapFromPartialObject($object) { return array( 'id' => (int)$object->getID(), );