-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
Fixed Query::paginate() #14
Conversation
Hi @Max13 , The required I somehow thought I had to pad the collection, but I did a mistake during testing - that's how we ended up here. I think its save to remove the public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
if ($page === null && isset($_GET[$page_name])) {
$this->page = $_GET[$page_name] > 0 ? intval($_GET[$page_name]) : 0;
} elseif ($page > 0) {
$this->page = $page;
}
$this->limit = $per_page;
return $this->get()->paginate($per_page, $this->page, $page_name);
} Do you want to update your PR or should I merge it and do the changes myself? :) Thanks for taking your time and willingness to contribute. I very much appreciate it 👍 |
if ( | ||
$page === null | ||
&& isset($_GET[$page_name]) | ||
&& $_GET[$page_name] > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think this condition is necessary (instead of ternary condition) because if $_GET[$page_name]
isn't positive, Query::$page
shouldn't be touched and should remain to it's default value: 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't $_GET[$page_name]
throw a notice if it isn't set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If $_GET[$page_name]
isn't set, a notice should be raised.
L:256 checks if $_GET[$page_name]
is set. If not, L:257 won't be checked, so it would jump the block and try the next condition (hence, without touching $this->page
which would remain to 1
)
Brain fails happen, I hope removing the unnecessary pad won't break anything in existing code. I forced-push the changes we agree on, and added comments. You're welcome, it's for the greater good and... me 😁 |
I don't understand the original intention of the array of value
true
in thepaginate()
method, so I assumed they are placeholders for whenQuery::get()
doesn't output messages (in case of a bug maybe).So I kept this behavior, while fixing #13 which I think is a bug.
If I misunderstood the behavior, please explain, I'll revert and fix my case.