-
Notifications
You must be signed in to change notification settings - Fork 93
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
Infinite Loop created in pager.php #23
Comments
I would love to see this resolved so there is no 'next page' link if there IS NO next page. it was driving me crazy as well as i was looping through all the next pages to get a full result set for accounts and subscriptions only to find out the last api call failed to return a result, so i had to add a condition for that. |
I had this problem over in #31. I posted my code over there that attempted to pager results. Can anyone get a pager going that shows X number of results per page? |
hey nate On Fri, Jun 8, 2012 at 11:55 AM, Nathan Haug <
will@blasthaus.com blasthaus |
Paging is done automatically for you, there is no need to manually page through the results. This code will scroll through all Active records $subscriptions = Recurly_SubscriptionList::getActive(); |
Yes I know it automatically retrieves additional results, what I needed was to say "show me the second page of 20 results, which start at result 21". I believe what I did 6 months ago is simply continue through the results until I got to the second page, then I started printing out the results. However as you might imagine this is incredibly inefficient; increasingly so as you get more pages. |
My question on paging the list of results is still open at #31, unrelated to this issue. |
I've run into a really weird issue, I spent some time working on it but was unable to track it down completely.
The basic issue is this: When you try to add a per_page parameter to the request, in my case, for invoices, and the per_page number is a squared number of the total number of records available, it creates an infinite loop inside of the Recurly_Pager->current() method.
Example: I have 6 invoices for a particular user. I create this request:
It creates an infinite loop.
If I set the page size to 4, or anything other than a number that can be squared to reach the total invoices, it works fine.
Here's the current code:
The problem happens inside of the
while()
loop. If we add&& sizeof($this->_objects) > 0
to thewhile()
, it partially fixes the problem, however, it creates an extravalid()
record that is blank, meaning if we use aforeach()
, we'll have a blank record.I've spent too much time trying to track it down already, if it becomes a big enough issue, I'll have to try to fix it, but hopefully y'all will figure it out before I do.
One thought, is that part of the problem might be that the API returns a
rel="next";
link in the header, even if there is no next page. Should that happen? If there's not another page, shouldn't it just leave that out? I think that would simplify the issue considerably.The text was updated successfully, but these errors were encountered: