From 01d376f501d8556569a22463bc5745b0cbed7902 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Mon, 27 May 2013 15:21:24 +1200 Subject: [PATCH] BUG Fixing problem where duplicate items appear on pages Reverts 13cdb07539d560f509605b836390de3317401fb4 and instead calls setLimitItems(false) on PaginatedList to tell it we've already limited the number of items to be shown. --- code/MSSQLDatabase.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/code/MSSQLDatabase.php b/code/MSSQLDatabase.php index fb65482..c832f5e 100644 --- a/code/MSSQLDatabase.php +++ b/code/MSSQLDatabase.php @@ -1418,7 +1418,11 @@ class MSSQLDatabase extends SS_Database { $objects = array(); foreach ($result as $row) { $current++; - $objects[] = DataObject::get_by_id($row['Source'], $row['ID']); + + // Select a subset for paging + if ($current >= $start && $current < $start + $pageLength) { + $objects[] = DataObject::get_by_id($row['Source'], $row['ID']); + } } if(isset($objects)) $results = new ArrayList($objects); @@ -1427,6 +1431,10 @@ class MSSQLDatabase extends SS_Database { $list->setPageStart($start); $list->setPageLength($pageLength); $list->setTotalItems($current+1); + + // The list has already been limited by the query above + $list->setLimitItems(false); + return $list; }