Welcome Guest, Not a member yet? Register   Sign In
Pagination problem 4.0.4
#1
Question 
(This post was last modified: 09-01-2020, 08:43 AM by Gary.)

I'm having a hiccup with latest builds of CI (4.0.4 as well as the last few dev builds that I've subsequently installed, after seeing there's been a few problems discussed pre-4.0.4 and also a current (still-outstanding) bug report related to pagination, though it seems to be parked, waiting for more info: https://github.com/codeigniter4/CodeIgni...ssues/3164).

Relevant points:

1) I'm using manual pagination in a manner similar to what's outlined here: https://codeigniter.com/user_guide/libra...pagination
2) My code has been working without (observed) problems for a while (besides for a recently discovered pre-upgrade problem where some of the links generated on the last page were repeats of previously listed items- which triggered the investigation into pagination issues and my upgrade to the official 4.0.4).  This point is for information only, and may well be a problem with my code [update: this appears to be a separate issue to do with the $builder->whereIn() function, as discussed here: https://forum.codeigniter.com/thread-77429.html].
3) Subsequent to upgrading to 4.0.4 (and one of recent dev builds), the auto-generated links to other pages has been broken.

If I change this bit of the store() routine in the system's Pager.php -

from:
Code:
if ($segment > 0 && $this->groups[$group]['currentPage'] > 0)
{
  $page = $this->groups[$group]['currentPage'];
}
$perPage = $perPage ?? $this->config->perPage;
$pageCount = (int)ceil($total / $perPage);
$this->groups[$group]['currentPage'] = $page > $pageCount ? $pageCount : $page;

to:
Code:
// if ($segment > 0 && $this->groups[$group]['currentPage'] > 0)
// {
//    $page = $this->groups[$group]['currentPage'];
// }
$perPage = $perPage ?? $this->config->perPage;
$pageCount = (int)ceil($total / $perPage);
$page = $page > $pageCount ? $pageCount : $page;
$this->groups[$group]['currentPage'] = $page > $pageCount ? $pageCount : $page;

then it seems to work again...

I did gloss over the documentation on Paging, and I don't notice anything that's changed in the Pagination for 4.0.4... so did I miss something, is there likely a bug in my code, or has a bug been introduced into the CI pagination code?
Reply


Messages In This Thread
Pagination problem 4.0.4 - by Gary - 08-30-2020, 03:07 PM
RE: Pagination problem 4.0.4 - by Gary - 09-05-2020, 02:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB