api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.39k stars 849 forks source link

Query parameters are incorrectly normalized in IriHelper #5221

Open 4rthem opened 1 year ago

4rthem commented 1 year ago

API Platform version(s) affected: 3.0.4

Description

If you pass array of array in query, the next page got from IriHelper is not correct.

How to reproduce

Call your API endpoint with multi-dimensional array params:

GET https://my-api/objects?filters[0][a]=foo&filters[0][b]=bar

In PHP we can access filters[0]['a'] and filters[0]['b']

But the next URL from hydra response is something like:

https://my-api/objects?page=2&filters[][a]=foo&filters[][b]=bar

So in PHP the filters structure is altered and filters[0]['b'] is not defined.

Possible Solution

Remove preg_replace('/%5B\d+%5D/', '%5B%5D', $query) from IriHelper::createIri.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.