Skip to content

Commit

Permalink
Fixed division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Nil Portugues Caldero committed Jun 13, 2016
1 parent 141906e commit ea1aa9a
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ public function findAll(Pageable $pageable = null)
$page = $pageable->pageNumber() - 1;
$page = ($page < 0) ? 1 : $page;

$options['limit'] = $pageable->pageSize();
$options['skip'] = $pageable->pageSize() * ($page);
$pageSize = $pageable->pageSize();
$pageSize = ($pageSize>0) ? $pageSize : 1;

$options['limit'] = $pageSize;
$options['skip'] = $pageSize * ($page);

$distinct = $pageable->distinctFields()->get();
if (count($distinct) > 0) {
Expand All @@ -47,7 +50,7 @@ public function findAll(Pageable $pageable = null)
$results = $collection->find($filterArray, $options)->toArray();
}

return new ResultPage($results, $total, $pageable->pageNumber(), ceil($total / $pageable->pageSize()));
return new ResultPage($results, $total, $pageable->pageNumber(), ceil($total / $pageSize));
}

$bsonDocumentArray = $collection->find([], $options);
Expand Down

0 comments on commit ea1aa9a

Please sign in to comment.