Fix bug in resumption tokens
This commit is contained in:
parent
f2cd77a8bd
commit
df0866c824
|
@ -218,7 +218,7 @@ class OAI2Server {
|
||||||
// Will we need a new ResumptionToken?
|
// Will we need a new ResumptionToken?
|
||||||
if ($records_count - $deliveredRecords > $maxItems) {
|
if ($records_count - $deliveredRecords > $maxItems) {
|
||||||
$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);
|
$expirationDatetime = gmstrftime('%Y-%m-%dT%TZ', time()+$this->token_valid);
|
||||||
} elseif (isset($this->args['resumptionToken'])) {
|
} elseif (isset($this->args['resumptionToken'])) {
|
||||||
// Last delivery, return empty ResumptionToken
|
// Last delivery, return empty ResumptionToken
|
||||||
|
@ -241,23 +241,17 @@ class OAI2Server {
|
||||||
$this->response->importFragment($meta_node, $fragment);
|
$this->response->importFragment($meta_node, $fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createResumptionToken($delivered_records) {
|
private function createResumptionToken($deliveredRecords, $metadataPrefix, $from, $until) {
|
||||||
list($usec, $sec) = explode(' ', microtime());
|
list($usec, $sec) = explode(' ', microtime());
|
||||||
$token = ((int)($usec*1000) + (int)($sec*1000));
|
$token = ((int)($usec*1000) + (int)($sec*1000));
|
||||||
$file = fopen ($this->token_prefix.$token, 'w');
|
$file = fopen($this->token_prefix.$token, 'w');
|
||||||
if($file == false) {
|
if($file == false) {
|
||||||
exit('Cannot write resumption token. Writing permission needs to be changed.');
|
exit('Cannot write resumption token. Writing permission needs to be changed.');
|
||||||
}
|
}
|
||||||
$values = array(
|
fputs($file, $deliveredRecords.'#');
|
||||||
'deliveredRecords' => $delivered_records,
|
fputs($file, $metadataPrefix.'#');
|
||||||
'metadataPrefix' => isset($this->args['metadataPrefix']) ? $this->args['metadataPrefix'] : '',
|
fputs($file, $from.'#');
|
||||||
'from' => isset($this->args['from']) ? $this->args['from'] : '',
|
fputs($file, $until);
|
||||||
'until' => isset($this->args['until']) ? $this->args['until'] : ''
|
|
||||||
);
|
|
||||||
fputs($file, $values['deliveredRecords'].'#');
|
|
||||||
fputs($file, $values['metadataPrefix'].'#');
|
|
||||||
fputs($file, $values['from'].'#');
|
|
||||||
fputs($file, $values['until'].'#');
|
|
||||||
fclose($file);
|
fclose($file);
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue