From 9242f08d5d3b0bca0ac5253b951d86a62eb65c91 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 11 Sep 2020 08:59:59 -0400
Subject: [PATCH] Fix bug: resumption tokens missing when paginating deleted
 records. - Resolves VUFIND-1429.

---
 module/VuFind/src/VuFind/OAI/Server.php | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/module/VuFind/src/VuFind/OAI/Server.php b/module/VuFind/src/VuFind/OAI/Server.php
index 56692fa34a7..7764068ca3a 100644
--- a/module/VuFind/src/VuFind/OAI/Server.php
+++ b/module/VuFind/src/VuFind/OAI/Server.php
@@ -812,7 +812,12 @@ class Server
             $this->attachNonDeleted($xml, $doc, $format, $headersOnly, $set);
             $currentCursor++;
         }
-        $nextCursorMark = $result->getCursorMark();
+        // We only need a cursor mark if we fetched results from Solr; if our
+        // $recordLimit is 0, it means that we're still in the process of
+        // retrieving deleted records, and we're only hitting Solr to obtain a
+        // total record count. Therefore, we don't want to change the cursor
+        // mark yet, or it will break pagination of deleted records.
+        $nextCursorMark = $recordLimit > 0 ? $result->getCursorMark() : '';
 
         // If our cursor didn't reach the last record, we need a resumption token!
         $listSize = $deletedCount + $nonDeletedCount;
-- 
GitLab