Skip to content

Commit

Permalink
Fix some division by 0 if the pagination is set to 0 items per page
Browse files Browse the repository at this point in the history
  • Loading branch information
Fl0Cri committed May 27, 2021
1 parent 7fde48f commit 5b62a57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/SearchResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function defineProperties()
'default' => 10,
'type' => 'string',
'required' => true,
'validationPattern' => '^([0-9]|10)$',
'validationPattern' => '^([1-9]|10)$',
'validationMessage' => 'Maximum results per page is limited to 10 by Google API',
],
'sendReferer' => [
Expand All @@ -68,7 +68,7 @@ public function onRun()
$this->search = get('q');
$this->currentPage = (int) get('page', 1);
// maximum per page results allowed from Google API
$this->resultPerPage = min(10, $this->property('resultPerPage'));
$this->resultPerPage = max(1, min(10, $this->property('resultPerPage')));
// maximum results allowed from Google API
$this->maxResults = 100;

Expand Down

0 comments on commit 5b62a57

Please sign in to comment.