Skip to content

Commit

Permalink
pager: override page if there's nothing to display
Browse files Browse the repository at this point in the history
  • Loading branch information
gerryd committed Aug 13, 2024
1 parent 5b9398d commit 11c2ec0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Skeleton/Pager/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,14 @@ public function page($all = false) {

$this->items = call_user_func_array([$this->classname, 'get_paged'], $params);
$this->item_count = call_user_func_array([$this->classname, 'count'], [$this->options['conditions'], $this->options['joins']]);

// The requested page is empty, so we have probably passed the last item
// page to the last page instead
if (count($this->items) === 0 && $this->item_count > 0) {
$this->options['page'] = ceil($this->item_count / $this->options['per_page']);
$params[2] = $this->options['page'];
$this->items = call_user_func_array([$this->classname, 'get_paged'], $params);
}
}

/**
Expand Down

0 comments on commit 11c2ec0

Please sign in to comment.