Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.11k stars 2.69k forks source link

BUG: API get member or contact categories resets after n+1 categories and just shows the same over and over again #29425

Open JonBendtsen opened 3 months ago

JonBendtsen commented 3 months ago

Bug

BUG: API get member or contact categories resets after n+1 categories and just shows the same over and over again.

Dolibarr Version

20.0.0-alpha + 18.0.5

Environment PHP

8.2.7

Environment Database

1:11.0.3+maria~ubu2204

Steps to reproduce the behavior and expected behavior

create 3 categories for members. Use the API to get all categories, you get 3 as expected. set limit to 1 and page to 0, 1, 2 and you get what you expect. page 3 is an error, page 4 and up shows page 0 result.

now, set limit to 2, and page to 0, 1, 2, 3, ... and you keep getting the same result over and over and over.

Attached files

get_member_categories_resets_after_n+1

JonBendtsen commented 3 months ago

SAME issues applies for getting categories of contacts

http://localhost/api/index.php/contacts/1/categories?sortfield=s.rowid&sortorder=ASC&limit=2&page=3

JonBendtsen commented 3 months ago

IF member and contact categories had pagination like explained here #29402, then I would not have to keep trying until it fails - which in case of member and contact categories it never fails, just loops forever. If I had pagination I could ask if that was present and if so I could just ask for that.