From df0866c82441b6f5bc8acf6c8e5c3029f34233f2 Mon Sep 17 00:00:00 2001 From: Sebastian Meyer Date: Thu, 21 Dec 2017 18:46:16 +0100 Subject: [PATCH] Fix bug in resumption tokens --- oai2server.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/oai2server.php b/oai2server.php index 0c0aac0..102cfd1 100644 --- a/oai2server.php +++ b/oai2server.php @@ -218,7 +218,7 @@ class OAI2Server { // Will we need a new ResumptionToken? if ($records_count - $deliveredRecords > $maxItems) { $deliveredRecords += $maxItems; - $restoken = $this->createResumptionToken($deliveredRecords); + $restoken = $this->createResumptionToken($deliveredRecords, $metadataPrefix, $from, $until); $expirationDatetime = gmstrftime('%Y-%m-%dT%TZ', time()+$this->token_valid); } elseif (isset($this->args['resumptionToken'])) { // Last delivery, return empty ResumptionToken @@ -241,23 +241,17 @@ class OAI2Server { $this->response->importFragment($meta_node, $fragment); } - private function createResumptionToken($delivered_records) { + private function createResumptionToken($deliveredRecords, $metadataPrefix, $from, $until) { list($usec, $sec) = explode(' ', microtime()); $token = ((int)($usec*1000) + (int)($sec*1000)); - $file = fopen ($this->token_prefix.$token, 'w'); + $file = fopen($this->token_prefix.$token, 'w'); if($file == false) { exit('Cannot write resumption token. Writing permission needs to be changed.'); } - $values = array( - 'deliveredRecords' => $delivered_records, - 'metadataPrefix' => isset($this->args['metadataPrefix']) ? $this->args['metadataPrefix'] : '', - 'from' => isset($this->args['from']) ? $this->args['from'] : '', - 'until' => isset($this->args['until']) ? $this->args['until'] : '' - ); - fputs($file, $values['deliveredRecords'].'#'); - fputs($file, $values['metadataPrefix'].'#'); - fputs($file, $values['from'].'#'); - fputs($file, $values['until'].'#'); + fputs($file, $deliveredRecords.'#'); + fputs($file, $metadataPrefix.'#'); + fputs($file, $from.'#'); + fputs($file, $until); fclose($file); return $token; }