-
Notifications
You must be signed in to change notification settings - Fork 144
Description
PHP Version
8.4.17
CodeIgniter4 Version
4.6.3
Shield Version
1.2.0
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
MariaDB 10.11.15
Did you customize Shield?
No
What happened?
Hello Shield!
When I try to paginate my users, I get results in page 1, but pages 2 or greater are empty :(
$authProvider = auth()->getProvider();
$users = $authProvider
->withIdentities()
->withGroups()
->withPermissions()
->orderBy("id")
->paginate(10, "default", 2);
The problem appears when I use withIdentities(), if I remove that then pagination works fine and page 2 or greater return the correct users.
From my limited understanding, the fetchIdentities calls $this->whereIn('id', $userIds) back on the UserModels own query builder to do the identity lookup. The call whereIn leaks into the shared query builder instance that was preserved by countAllResults(false), since pagination in CodeIgniter 4 is not one query but two (the first query sets countAllResults to false so the state can be reused by the second query).
Thank you.
Steps to Reproduce
This works (results are returned)
$authProvider = auth()->getProvider();
$users = $authProvider
->withGroups()
->withPermissions()
->orderBy("id")
->paginate(10, "default", 2);
This does NOT work (no results at page 2 or greater)
$authProvider = auth()->getProvider();
$users = $authProvider
->withIdentities()
->withGroups()
->withPermissions()
->orderBy("id")
->paginate(10, "default", 2);
Expected Output
I expect to see results returned by the paginate function.
Anything else?
CodeIgniter is awesome, thank you for all your hard work :)