-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Shifted" $this->page
between isLastPage()
and applyPagination()
in pagination
#343
Comments
Hey @boryn thank you for bringing this to my attention. I also have noticed this when I was last testing and playing around with the paginator in a project of mine. I'll have another look in a fresh Laravel application this week. If it turns out that the |
Yes, please check it, as IMHO there is something unpredictable right now. Variable name maybe could be I must admit I miss another variable like return count($this->getPageItems($response, $this->getOriginalRequest())) === 0; and this would be for sure more convenient: return $this->currentResults === 0; |
Hey @boryn I have created a PR first which fixes v1 of the pagination plugin (I'll then PR the fix for v2) to cover both Saloon versions but you were right, the property was wrong - thank you for pointing this out to me! Would you mind reviewing this PR please: saloonphp/pagination-plugin#10 Thank you |
I even was not aware there was the same problem with v1. Probably I was using a different logic then. Now I don't use it any more, so I cannot test it empirically, but the changes in the code look all right! |
When I say v1, I mean Pagination v2 but for Saloon v2 + v3. Too many versions 🤣 Thank you for looking at it. I've just released an update for you! |
So if it is for Pagination v2 and Saloon v3 as well, so I will give it some tests the following days. |
I'm not sure here, maybe it's on purpose or maybe I cannot debug it properly.
I connect with an API which returns
'total_pages'
, so the most natural way was to implement this in theisLastPage()
method:Unfortunately, it seems it does not reach the final page. I made tests with simple result set, I have 3 items, I get 1 item per page so in total I have 3 pages. So I should iterate three times, but unfortunately I get two results.
When I put debugging messages in both methods like this:
echo ("page in isLastPage: {$this->page}\n");
echo ("page in applyPagination: {$this->page}\n");
I get:
page in applyPagination: 1
&per_page=1&page=1
page in isLastPage: 2
So you can see that page number in
isLastPage()
already jumped to 2. So with second iteration it will have the page number of 3 which equals to'total_pages'
and we never reach the last third iteration.The text was updated successfully, but these errors were encountered: