Skip to content

Commit

Permalink
#766 Fix return empty string for integer variables. Renaming maxRecor…
Browse files Browse the repository at this point in the history
…ds parameter.
  • Loading branch information
haogatyp committed Oct 5, 2023
1 parent 7967b50 commit 42c37f6
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions modules/oai/models/DefaultServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ class Oai_Model_DefaultServer extends Application_Model_Abstract
/** @var string */
private $sampleIdentifier;

/** @var string */
/** @var int */
private $maxListIdentifiers;

/** @var string */
/** @var int */
private $maxListRecords;

/** @var string */
Expand Down Expand Up @@ -492,12 +492,12 @@ protected function handleListSets()
/**
* Helper method for handling lists.
*
* @param mixed $maxRecords
* @param int $maxItems
*/
private function handlingOfLists(array &$oaiRequest, $maxRecords)
private function handlingOfLists(array &$oaiRequest, $maxItems)
{
if (true === empty($maxRecords)) {
$maxRecords = 100;
if (empty($maxItems)) {
$maxItems = 100;
}

$repIdentifier = $this->getRepositoryIdentifier();
Expand All @@ -509,7 +509,7 @@ private function handlingOfLists(array &$oaiRequest, $maxRecords)
// do some initialisation
$cursor = 0;
$totalIds = 0;
$start = $maxRecords + 1;
$start = $maxItems + 1;
$restIds = [];

$metadataPrefix = null;
Expand All @@ -532,7 +532,7 @@ private function handlingOfLists(array &$oaiRequest, $maxRecords)
}

$cursor = $token->getStartPosition() - 1;
$start = $token->getStartPosition() + $maxRecords;
$start = $token->getStartPosition() + $maxItems;
$totalIds = $token->getTotalIds();
$restIds = $token->getDocumentIds();
$metadataPrefix = $token->getMetadataPrefix();
Expand All @@ -550,7 +550,7 @@ private function handlingOfLists(array &$oaiRequest, $maxRecords)
}

// handling of document ids
$workIds = array_splice($restIds, 0, $maxRecords);
$workIds = array_splice($restIds, 0, $maxItems);

foreach ($workIds as $docId) {
$document = Document::get($docId);
Expand Down Expand Up @@ -1066,7 +1066,7 @@ public function setSampleIdentifier($sampleId)
*/
public function getMaxListIdentifiers()
{
return $this->maxListIdentifiers ?? '';
return $this->maxListIdentifiers ?? 0;
}

/**
Expand All @@ -1086,7 +1086,7 @@ public function setMaxListIdentifiers($maxListIds)
*/
public function getMaxListRecords()
{
return $this->maxListRecords ?? '';
return $this->maxListRecords ?? 0;
}

/**
Expand Down

0 comments on commit 42c37f6

Please sign in to comment.