From 46f70c414e17108421e8e175b19601017ec24bdb Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Mon, 7 Mar 2022 12:37:13 +1300 Subject: [PATCH] ENH: Respect sort and limit arguments These parameters are defined in the PHPDocs for `Report` and are technically part of the method signature. They should be respected and in the case of the new default limit in silverstripe/silverstripe-reports#139 this could have performance ramifications for large datasets. --- src/Reports/PagesWithoutReviewScheduleReport.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Reports/PagesWithoutReviewScheduleReport.php b/src/Reports/PagesWithoutReviewScheduleReport.php index 0f7b402..fb3a0f2 100644 --- a/src/Reports/PagesWithoutReviewScheduleReport.php +++ b/src/Reports/PagesWithoutReviewScheduleReport.php @@ -107,7 +107,7 @@ public function columns() * * @return SS_List */ - public function sourceRecords($params = []) + public function sourceRecords($params = [], $sort = null, $limit = null) { Versioned::set_stage(Versioned::DRAFT); @@ -125,7 +125,13 @@ public function sourceRecords($params = []) )); } - $records->sort("ParentID"); + if ($sort !== null) { + $sort = 'ParentID'; + } + $records->sort($sort); + if ($limit !== null) { + $records = $records->limit($limit); + } $records = $records->toArray(); // Trim out calculated values