-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[2.0.x] The Model Paginator now iterates over the models. #10251
[2.0.x] The Model Paginator now iterates over the models. #10251
Conversation
@SidRoberts I've tried it, it does not solve the problem. |
Looks good. Valid() previously moved the pointer to the next position which is a non-standard behaviour. Next() has to be called. I'm currently reviewing #10100 and look for other occurrences. I did not anticipate such problems... |
$robots = Robots::find();
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$limit = isset($_GET['limit']) ? $_GET['limit'] : 3;
$paginator = new Phalcon\Paginator\Adapter\Model([
'data' => $robots,
'limit' => $limit,
'page' => $page
]);
$paginate = $paginator->getPaginate();
echo 'Items: ' . count($robots) . '<br>';
echo 'Page: ' . $page . ' / ' . $paginate->total_pages . '<br>';
echo 'Results: ';
foreach ($paginate->items as $item) {
echo $item->id . ',';
} 2.0.x (fail)Test 1 ($page = 1)
Test 2 ($page = 2)
Test 3 ($page = 5)
Test 4 ($page = 17)
2.0.0 (success)Test 1 ($page = 1)
Test 2 ($page = 2)
Test 3 ($page = 5)
Test 4 ($page = 17)
|
@patrick-zippenfenig Please use |
#10253 should fix the issues mentioned by @KorsaR-ZN. valid() is also used in volt.zep#L248 but correctly implemented. |
👍 |
[2.0.x] The Model Paginator now iterates over the models.
Thanks |
@KorsaR-ZN, could you check your code to see if this solves the problem?Update: This does solve an issue in the Paginator, but see also #10253 for the real fix.