Welcome Guest, Not a member yet? Register   Sign In
Fix Paginate
#1
Wink 

This code don't work. The segment has a error.
The fix:
system\BaseModel.php

Before
PHP Code:
public function paginate(?int $perPage nullstring $group 'default', ?int $page nullint $segment 0)
    {
        $pager Services::pager(nullnullfalse);

        if ($segment) {
            $pager->setSegment($segment);
        


After

PHP Code:
public function paginate(?int $perPage nullstring $group 'default', ?int $page nullint $segment 0)
    {
        $pager Services::pager(nullnullfalse);

        if ($segment) {
            $pager->setSegment($segment,$group);
        
Reply
#2

How do you raise the error?
Reply
#3

(This post was last modified: 02-19-2022, 03:37 PM by Gary.)

I had a problem with the pager, from perhaps a year ago...

I did put a few posts about it on the forum after I was convinced there was a problem, but nobody else seemed to experience it (?).

My fix is to change "false" to TRUE in the following line (# 37) in ArrayPaginationModel.php (which I've had to do for every recent revision of CI4, and which still fixes it for me):

$pager = \Config\Services::pager(null, null, TRUE); // default was FALSE, but then stops makeLinks working (since it overwrites the call to store()) [NOTE: not sure these comments apply to the last couple of CI4 revisions, but they did at the time]
Reply
#4

(02-15-2022, 09:38 PM)kenjis Wrote: How do you raise the error?


the problem is that pagination by segments doesn't work.

With the second code that I have put, the problem is corrected. 
this is the file with the problem: system\BaseModel.php

You have to pass the $group parameter to the setSegment function
Reply
#5

I just wanted to know how to reproduce the bug.
Because I was not able to write test code to reproduce the bug.

Anyway it already was fixed in the develop branch, and it will be included in v4.2.0.
Reply
#6

(02-23-2022, 05:57 PM)kenjis Wrote: I just wanted to know how to reproduce the bug.
Because I was not able to write test code to reproduce the bug.

Anyway it already was fixed in the develop branch, and it will be included in v4.2.0.



Here is an example when the error happens.
when doing paginate on objects, it only works through "get", with segments it doesn't paginate well

PHP Code:
$producto_model=new Producto_Model();

$producto_model->asArray()->where($array_carga_object)->paginate(20,'paginacion_listado',null,$num_segmento_paginacion); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB